Passed
Push — master ( 4cf75d...361a24 )
by Brian
05:01
created
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +607 added lines, -607 removed lines patch added patch discarded remove patch
@@ -14,91 +14,91 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29 29
 	
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct(){
38
+     * Class constructor.
39
+     */
40
+    public function __construct(){
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect') );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
68 68
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
-		do_action( 'getpaid_init_admin_hooks', $this );
78
-
79
-		// Setup/welcome
80
-		if ( ! empty( $_GET['page'] ) ) {
81
-			switch ( $_GET['page'] ) {
82
-				case 'gp-setup' :
83
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
84
-					break;
85
-			}
86
-		}
87
-
88
-    }
89
-
90
-    /**
91
-	 * Register admin scripts
92
-	 *
93
-	 */
94
-	public function enqeue_scripts() {
69
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
+        add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
+        add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
+        do_action( 'getpaid_init_admin_hooks', $this );
78
+
79
+        // Setup/welcome
80
+        if ( ! empty( $_GET['page'] ) ) {
81
+            switch ( $_GET['page'] ) {
82
+                case 'gp-setup' :
83
+                    include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
84
+                    break;
85
+            }
86
+        }
87
+
88
+    }
89
+
90
+    /**
91
+     * Register admin scripts
92
+     *
93
+     */
94
+    public function enqeue_scripts() {
95 95
         global $current_screen, $pagenow;
96 96
 
97
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
98
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
97
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
98
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
99 99
 
100 100
         if ( ! empty( $current_screen->post_type ) ) {
101
-			$page = $current_screen->post_type;
101
+            $page = $current_screen->post_type;
102 102
         }
103 103
 
104 104
         // General styles.
@@ -119,54 +119,54 @@  discard block
 block discarded – undo
119 119
         }
120 120
 
121 121
         // Payment form scripts.
122
-		if ( 'wpi_payment_form' == $page && $editing ) {
122
+        if ( 'wpi_payment_form' == $page && $editing ) {
123 123
             $this->load_payment_form_scripts();
124 124
         }
125 125
 
126
-		if ( $page == 'wpinv-subscriptions' ) {
127
-			wp_enqueue_script( 'postbox' );
128
-		}
126
+        if ( $page == 'wpinv-subscriptions' ) {
127
+            wp_enqueue_script( 'postbox' );
128
+        }
129 129
 
130 130
     }
131 131
 
132 132
     /**
133
-	 * Returns admin js translations.
134
-	 *
135
-	 */
136
-	protected function get_admin_i18() {
133
+     * Returns admin js translations.
134
+     *
135
+     */
136
+    protected function get_admin_i18() {
137 137
         global $post;
138 138
 
139
-		$date_range = array(
140
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
141
-		);
139
+        $date_range = array(
140
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
141
+        );
142 142
 
143
-		if ( $date_range['period'] == 'custom' ) {
143
+        if ( $date_range['period'] == 'custom' ) {
144 144
 			
145
-			if ( isset( $_GET['from'] ) ) {
146
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
147
-			}
145
+            if ( isset( $_GET['from'] ) ) {
146
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
147
+            }
148 148
 
149
-			if ( isset( $_GET['to'] ) ) {
150
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
151
-			}
149
+            if ( isset( $_GET['to'] ) ) {
150
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
151
+            }
152 152
 
153
-		}
153
+        }
154 154
 
155 155
         $i18n = array(
156 156
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
157 157
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
158
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
159
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
160
-			'rest_root'                 => esc_url_raw( rest_url() ),
161
-			'date_range'                => $date_range,
158
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
159
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
160
+            'rest_root'                 => esc_url_raw( rest_url() ),
161
+            'date_range'                => $date_range,
162 162
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
163 163
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
164 164
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
165 165
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
166 166
             'tax'                       => wpinv_tax_amount(),
167 167
             'discount'                  => 0,
168
-			'currency_symbol'           => wpinv_currency_symbol(),
169
-			'currency'                  => wpinv_get_currency(),
168
+            'currency_symbol'           => wpinv_currency_symbol(),
169
+            'currency'                  => wpinv_get_currency(),
170 170
             'currency_pos'              => wpinv_currency_position(),
171 171
             'thousand_sep'              => wpinv_thousands_separator(),
172 172
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -186,118 +186,118 @@  discard block
 block discarded – undo
186 186
             'item_description'          => __( 'Item Description', 'invoicing' ),
187 187
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
188 188
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
189
-			'searching'                 => __( 'Searching', 'invoicing' ),
190
-			'loading'                   => __( 'Loading...', 'invoicing' ),
191
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
192
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
189
+            'searching'                 => __( 'Searching', 'invoicing' ),
190
+            'loading'                   => __( 'Loading...', 'invoicing' ),
191
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
192
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
193 193
         );
194 194
 
195
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
195
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
196 196
 
197
-			$invoice              = new WPInv_Invoice( $post );
198
-			$i18n['save_invoice'] = sprintf(
199
-				__( 'Save %s', 'invoicing' ),
200
-				ucfirst( $invoice->get_invoice_quote_type() )
201
-			);
197
+            $invoice              = new WPInv_Invoice( $post );
198
+            $i18n['save_invoice'] = sprintf(
199
+                __( 'Save %s', 'invoicing' ),
200
+                ucfirst( $invoice->get_invoice_quote_type() )
201
+            );
202 202
 
203
-			$i18n['invoice_description'] = sprintf(
204
-				__( '%s Description', 'invoicing' ),
205
-				ucfirst( $invoice->get_invoice_quote_type() )
206
-			);
203
+            $i18n['invoice_description'] = sprintf(
204
+                __( '%s Description', 'invoicing' ),
205
+                ucfirst( $invoice->get_invoice_quote_type() )
206
+            );
207 207
 
208
-		}
209
-		return $i18n;
210
-	}
208
+        }
209
+        return $i18n;
210
+    }
211 211
 
212
-	/**
213
-	 * Change the admin footer text on GetPaid admin pages.
214
-	 *
215
-	 * @since  2.0.0
216
-	 * @param  string $footer_text
217
-	 * @return string
218
-	 */
219
-	public function admin_footer_text( $footer_text ) {
220
-		global $current_screen;
212
+    /**
213
+     * Change the admin footer text on GetPaid admin pages.
214
+     *
215
+     * @since  2.0.0
216
+     * @param  string $footer_text
217
+     * @return string
218
+     */
219
+    public function admin_footer_text( $footer_text ) {
220
+        global $current_screen;
221 221
 
222
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
222
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
223 223
 
224 224
         if ( ! empty( $current_screen->post_type ) ) {
225
-			$page = $current_screen->post_type;
225
+            $page = $current_screen->post_type;
226 226
         }
227 227
 
228 228
         // General styles.
229 229
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
230 230
 
231
-			// Change the footer text
232
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
233
-
234
-				$rating_url  = esc_url(
235
-					wp_nonce_url(
236
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
237
-						'getpaid-nonce',
238
-						'getpaid-nonce'
239
-						)
240
-				);
241
-
242
-				$footer_text = sprintf(
243
-					/* translators: %s: five stars */
244
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
245
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246
-				);
247
-
248
-			} else {
249
-
250
-				$footer_text = sprintf(
251
-					/* translators: %s: GetPaid */
252
-					__( 'Thank you for using %s!', 'invoicing' ),
253
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254
-				);
255
-
256
-			}
257
-
258
-		}
259
-
260
-		return $footer_text;
261
-	}
262
-
263
-	/**
264
-	 * Redirects to wp.org to rate the plugin.
265
-	 *
266
-	 * @since  2.0.0
267
-	 */
268
-	public function redirect_to_wordpress_rating_page() {
269
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
270
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
271
-		exit;
272
-	}
273
-
274
-    /**
275
-	 * Loads payment form js.
276
-	 *
277
-	 */
278
-	protected function load_payment_form_scripts() {
231
+            // Change the footer text
232
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
233
+
234
+                $rating_url  = esc_url(
235
+                    wp_nonce_url(
236
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
237
+                        'getpaid-nonce',
238
+                        'getpaid-nonce'
239
+                        )
240
+                );
241
+
242
+                $footer_text = sprintf(
243
+                    /* translators: %s: five stars */
244
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
245
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246
+                );
247
+
248
+            } else {
249
+
250
+                $footer_text = sprintf(
251
+                    /* translators: %s: GetPaid */
252
+                    __( 'Thank you for using %s!', 'invoicing' ),
253
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254
+                );
255
+
256
+            }
257
+
258
+        }
259
+
260
+        return $footer_text;
261
+    }
262
+
263
+    /**
264
+     * Redirects to wp.org to rate the plugin.
265
+     *
266
+     * @since  2.0.0
267
+     */
268
+    public function redirect_to_wordpress_rating_page() {
269
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
270
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
271
+        exit;
272
+    }
273
+
274
+    /**
275
+     * Loads payment form js.
276
+     *
277
+     */
278
+    protected function load_payment_form_scripts() {
279 279
         global $post;
280 280
 
281 281
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
282
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
283
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
282
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
283
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
284 284
 
285
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
286
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ),  $version );
285
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
286
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ),  $version );
287 287
 
288
-		wp_localize_script(
288
+        wp_localize_script(
289 289
             'wpinv-admin-payment-form-script',
290 290
             'wpinvPaymentFormAdmin',
291 291
             array(
292
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
293
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
294
-				'currency'      => wpinv_currency_symbol(),
295
-				'position'      => wpinv_currency_position(),
296
-				'decimals'      => (int) wpinv_decimals(),
297
-				'thousands_sep' => wpinv_thousands_separator(),
298
-				'decimals_sep'  => wpinv_decimal_separator(),
299
-				'form_items'    => gepaid_get_form_items( $post->ID ),
300
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
292
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
293
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
294
+                'currency'      => wpinv_currency_symbol(),
295
+                'position'      => wpinv_currency_position(),
296
+                'decimals'      => (int) wpinv_decimals(),
297
+                'thousands_sep' => wpinv_thousands_separator(),
298
+                'decimals_sep'  => wpinv_decimal_separator(),
299
+                'form_items'    => gepaid_get_form_items( $post->ID ),
300
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
301 301
             )
302 302
         );
303 303
 
@@ -306,20 +306,20 @@  discard block
 block discarded – undo
306 306
     }
307 307
 
308 308
     /**
309
-	 * Add our classes to admin pages.
309
+     * Add our classes to admin pages.
310 310
      *
311 311
      * @param string $classes
312 312
      * @return string
313
-	 *
314
-	 */
313
+     *
314
+     */
315 315
     public function admin_body_class( $classes ) {
316
-		global $pagenow, $post, $current_screen;
316
+        global $pagenow, $post, $current_screen;
317 317
 
318 318
 
319 319
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
320 320
 
321 321
         if ( ! empty( $current_screen->post_type ) ) {
322
-			$page = $current_screen->post_type;
322
+            $page = $current_screen->post_type;
323 323
         }
324 324
 
325 325
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -328,68 +328,68 @@  discard block
 block discarded – undo
328 328
 
329 329
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
330 330
             $classes .= ' wpinv-cpt wpinv';
331
-		}
331
+        }
332 332
 		
333
-		if ( getpaid_is_invoice_post_type( $page ) ) {
333
+        if ( getpaid_is_invoice_post_type( $page ) ) {
334 334
             $classes .= ' getpaid-is-invoice-cpt';
335 335
         }
336 336
 
337
-		return $classes;
337
+        return $classes;
338 338
     }
339 339
 
340 340
     /**
341
-	 * Maybe show the AyeCode Connect Notice.
342
-	 */
343
-	public function init_ayecode_connect_helper(){
341
+     * Maybe show the AyeCode Connect Notice.
342
+     */
343
+    public function init_ayecode_connect_helper(){
344 344
 
345
-		// Register with the deactivation survey class.
346
-		AyeCode_Deactivation_Survey::instance(array(
347
-			'slug'		        => 'invoicing',
348
-			'version'	        => WPINV_VERSION,
349
-			'support_url'       => 'https://wpgetpaid.com/support/',
350
-			'documentation_url' => 'https://docs.wpgetpaid.com/',
351
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
352
-		));
345
+        // Register with the deactivation survey class.
346
+        AyeCode_Deactivation_Survey::instance(array(
347
+            'slug'		        => 'invoicing',
348
+            'version'	        => WPINV_VERSION,
349
+            'support_url'       => 'https://wpgetpaid.com/support/',
350
+            'documentation_url' => 'https://docs.wpgetpaid.com/',
351
+            'activated'         => (int) get_option( 'gepaid_installed_on' ),
352
+        ));
353 353
 
354 354
         new AyeCode_Connect_Helper(
355 355
             array(
356
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
357
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
358
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
359
-				'connect_button'    => __("Connect Site","invoicing"),
360
-				'connecting_button'    => __("Connecting...","invoicing"),
361
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
362
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
356
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
357
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
358
+                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
359
+                'connect_button'    => __("Connect Site","invoicing"),
360
+                'connecting_button'    => __("Connecting...","invoicing"),
361
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
362
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
363 363
             ),
364 364
             array( 'wpi-addons' )
365 365
         );
366 366
 
367 367
     }
368 368
 
369
-	/**
370
-	 * Redirect users to settings on activation.
371
-	 *
372
-	 * @return void
373
-	 */
374
-	public function activation_redirect() {
369
+    /**
370
+     * Redirect users to settings on activation.
371
+     *
372
+     * @return void
373
+     */
374
+    public function activation_redirect() {
375 375
 
376
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
376
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
377 377
 
378
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
379
-			return;
380
-		}
378
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
379
+            return;
380
+        }
381 381
 
382
-		// Bail if activating from network, or bulk
383
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
384
-			return;
385
-		}
382
+        // Bail if activating from network, or bulk
383
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
384
+            return;
385
+        }
386 386
 
387
-	    update_option( 'wpinv_redirected_to_settings', 1 );
387
+        update_option( 'wpinv_redirected_to_settings', 1 );
388 388
 
389 389
         wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
390 390
         exit;
391 391
 
392
-	}
392
+    }
393 393
 
394 394
     /**
395 395
      * Fires an admin action after verifying that a user can fire them.
@@ -403,539 +403,539 @@  discard block
 block discarded – undo
403 403
 
404 404
     }
405 405
 
406
-	/**
406
+    /**
407 407
      * Duplicate invoice.
408
-	 * 
409
-	 * @param array $args
408
+     * 
409
+     * @param array $args
410 410
      */
411 411
     public function duplicate_invoice( $args ) {
412 412
 
413
-		if ( empty( $args['invoice_id'] ) ) {
414
-			return;
415
-		}
413
+        if ( empty( $args['invoice_id'] ) ) {
414
+            return;
415
+        }
416 416
 
417
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
417
+        $invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
418 418
 
419
-		if ( ! $invoice->exists() ) {
420
-			return;
421
-		}
419
+        if ( ! $invoice->exists() ) {
420
+            return;
421
+        }
422 422
 
423
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
424
-		$new_invoice->save();
423
+        $new_invoice = getpaid_duplicate_invoice( $invoice );
424
+        $new_invoice->save();
425 425
 
426
-		if ( $new_invoice->exists() ) {
426
+        if ( $new_invoice->exists() ) {
427 427
 
428
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
428
+            getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
429 429
 
430
-			wp_safe_redirect(
431
-				add_query_arg(
432
-					array(
433
-						'action' => 'edit',
434
-						'post' => $new_invoice->get_id(),
435
-					),
436
-					admin_url( 'post.php' )
437
-				)
438
-			);
439
-			exit;
430
+            wp_safe_redirect(
431
+                add_query_arg(
432
+                    array(
433
+                        'action' => 'edit',
434
+                        'post' => $new_invoice->get_id(),
435
+                    ),
436
+                    admin_url( 'post.php' )
437
+                )
438
+            );
439
+            exit;
440 440
 
441
-		}
441
+        }
442 442
 
443
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
443
+        getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
444 444
 
445
-	}
445
+    }
446 446
 
447
-	/**
447
+    /**
448 448
      * Sends a payment reminder to a customer.
449
-	 * 
450
-	 * @param array $args
449
+     * 
450
+     * @param array $args
451 451
      */
452 452
     public function duplicate_payment_form( $args ) {
453 453
 
454
-		if ( empty( $args['form_id'] ) ) {
455
-			return;
456
-		}
457
-
458
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
454
+        if ( empty( $args['form_id'] ) ) {
455
+            return;
456
+        }
459 457
 
460
-		if ( ! $form->exists() ) {
461
-			return;
462
-		}
458
+        $form = new GetPaid_Payment_Form( (int) $args['form_id'] );
463 459
 
464
-		$new_form = new GetPaid_Payment_Form();
465
-		$new_form->set_author( $form->get_author( 'edit' ) );
466
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
467
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
468
-		$new_form->set_items( $form->get_items( 'edit' ) );
469
-		$new_form->save();
460
+        if ( ! $form->exists() ) {
461
+            return;
462
+        }
470 463
 
471
-		if ( $new_form->exists() ) {
472
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
473
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
474
-		} else {
475
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
477
-		}
464
+        $new_form = new GetPaid_Payment_Form();
465
+        $new_form->set_author( $form->get_author( 'edit' ) );
466
+        $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
467
+        $new_form->set_elements( $form->get_elements( 'edit' ) );
468
+        $new_form->set_items( $form->get_items( 'edit' ) );
469
+        $new_form->save();
470
+
471
+        if ( $new_form->exists() ) {
472
+            $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
473
+            $url = get_edit_post_link( $new_form->get_id(), 'edit' );
474
+        } else {
475
+            $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
+            $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
477
+        }
478 478
 
479
-		wp_redirect( $url );
480
-		exit;
481
-	}
479
+        wp_redirect( $url );
480
+        exit;
481
+    }
482 482
 
483
-	/**
483
+    /**
484 484
      * Sends a payment reminder to a customer.
485
-	 * 
486
-	 * @param array $args
485
+     * 
486
+     * @param array $args
487 487
      */
488 488
     public function send_customer_invoice( $args ) {
489
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
489
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
490 490
 
491
-		if ( $sent ) {
492
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
493
-		} else {
494
-			$this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
495
-		}
491
+        if ( $sent ) {
492
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
493
+        } else {
494
+            $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
495
+        }
496 496
 
497
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
498
-		exit;
499
-	}
497
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
498
+        exit;
499
+    }
500 500
 
501
-	/**
501
+    /**
502 502
      * Sends a payment reminder to a customer.
503
-	 * 
504
-	 * @param array $args
503
+     * 
504
+     * @param array $args
505 505
      */
506 506
     public function send_customer_payment_reminder( $args ) {
507
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
507
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
508 508
 
509
-		if ( $sent ) {
510
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
511
-		} else {
512
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
513
-		}
509
+        if ( $sent ) {
510
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
511
+        } else {
512
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
513
+        }
514 514
 
515
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
516
-		exit;
517
-	}
515
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
516
+        exit;
517
+    }
518 518
 
519
-	/**
519
+    /**
520 520
      * Resets tax rates.
521
-	 * 
521
+     * 
522 522
      */
523 523
     public function admin_reset_tax_rates() {
524 524
 
525
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
526
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
527
-		exit;
525
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
526
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
527
+        exit;
528 528
 
529
-	}
529
+    }
530 530
 
531
-	/**
531
+    /**
532 532
      * Resets admin pages.
533
-	 * 
533
+     * 
534 534
      */
535 535
     public function admin_create_missing_pages() {
536
-		$installer = new GetPaid_Installer();
537
-		$installer->create_pages();
538
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
539
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
540
-		exit;
541
-	}
542
-
543
-	/**
536
+        $installer = new GetPaid_Installer();
537
+        $installer->create_pages();
538
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
539
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
540
+        exit;
541
+    }
542
+
543
+    /**
544 544
      * Creates an missing admin tables.
545
-	 * 
545
+     * 
546 546
      */
547 547
     public function admin_create_missing_tables() {
548
-		global $wpdb;
549
-		$installer = new GetPaid_Installer();
548
+        global $wpdb;
549
+        $installer = new GetPaid_Installer();
550 550
 
551
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
552
-			$installer->create_subscriptions_table();
551
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
552
+            $installer->create_subscriptions_table();
553 553
 
554
-			if ( $wpdb->last_error !== '' ) {
555
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
556
-			}
557
-		}
554
+            if ( $wpdb->last_error !== '' ) {
555
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
556
+            }
557
+        }
558 558
 
559
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
560
-			$installer->create_invoices_table();
559
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
560
+            $installer->create_invoices_table();
561 561
 
562
-			if ( $wpdb->last_error !== '' ) {
563
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
564
-			}
565
-		}
562
+            if ( $wpdb->last_error !== '' ) {
563
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
564
+            }
565
+        }
566 566
 
567
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
568
-			$installer->create_invoice_items_table();
567
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
568
+            $installer->create_invoice_items_table();
569 569
 
570
-			if ( $wpdb->last_error !== '' ) {
571
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
572
-			}
573
-		}
570
+            if ( $wpdb->last_error !== '' ) {
571
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
572
+            }
573
+        }
574 574
 
575
-		if ( ! $this->has_notices() ) {
576
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
577
-		}
575
+        if ( ! $this->has_notices() ) {
576
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
577
+        }
578 578
 
579
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
580
-		exit;
581
-	}
579
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
580
+        exit;
581
+    }
582 582
 
583
-	/**
583
+    /**
584 584
      * Migrates old invoices to the new database tables.
585
-	 * 
585
+     * 
586 586
      */
587 587
     public function admin_migrate_old_invoices() {
588 588
 
589
-		// Migrate the invoices.
590
-		$installer = new GetPaid_Installer();
591
-		$installer->migrate_old_invoices();
589
+        // Migrate the invoices.
590
+        $installer = new GetPaid_Installer();
591
+        $installer->migrate_old_invoices();
592 592
 
593
-		// Show an admin message.
594
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
593
+        // Show an admin message.
594
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
595 595
 
596
-		// Redirect the admin.
597
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
598
-		exit;
596
+        // Redirect the admin.
597
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
598
+        exit;
599 599
 
600
-	}
600
+    }
601 601
 
602
-	/**
602
+    /**
603 603
      * Download customers.
604
-	 * 
604
+     * 
605 605
      */
606 606
     public function admin_download_customers() {
607
-		global $wpdb;
607
+        global $wpdb;
608 608
 
609
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
609
+        $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
610 610
 
611
-		header( "Content-Type:text/csv" );
612
-		header( "Content-Disposition:attachment;filename=customers.csv" );
611
+        header( "Content-Type:text/csv" );
612
+        header( "Content-Disposition:attachment;filename=customers.csv" );
613 613
 
614
-		$post_types = '';
614
+        $post_types = '';
615 615
 
616
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
617
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
618
-		}
616
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
617
+            $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
618
+        }
619 619
 
620
-		$post_types = rtrim( $post_types, ' OR' );
620
+        $post_types = rtrim( $post_types, ' OR' );
621 621
 
622
-		$customers = $wpdb->get_col(
623
-			$wpdb->prepare(
624
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
625
-			)
626
-		);
622
+        $customers = $wpdb->get_col(
623
+            $wpdb->prepare(
624
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
625
+            )
626
+        );
627 627
 
628
-		$columns = array(
629
-			'name'     => __( 'Name', 'invoicing' ),
630
-			'email'    => __( 'Email', 'invoicing' ),
631
-			'country'  => __( 'Country', 'invoicing' ),
632
-			'state'    => __( 'State', 'invoicing' ),
633
-			'city'     => __( 'City', 'invoicing' ),
634
-			'zip'      => __( 'ZIP', 'invoicing' ),
635
-			'address'  => __( 'Address', 'invoicing' ),
636
-			'phone'    => __( 'Phone', 'invoicing' ),
637
-			'company'  => __( 'Company', 'invoicing' ),
638
-			'company_id'  => __( 'Company ID', 'invoicing' ),
639
-			'invoices' => __( 'Invoices', 'invoicing' ),
640
-			'total_raw' => __( 'Total Spend', 'invoicing' ),
641
-			'signup'   => __( 'Date created', 'invoicing' ),
642
-		);
628
+        $columns = array(
629
+            'name'     => __( 'Name', 'invoicing' ),
630
+            'email'    => __( 'Email', 'invoicing' ),
631
+            'country'  => __( 'Country', 'invoicing' ),
632
+            'state'    => __( 'State', 'invoicing' ),
633
+            'city'     => __( 'City', 'invoicing' ),
634
+            'zip'      => __( 'ZIP', 'invoicing' ),
635
+            'address'  => __( 'Address', 'invoicing' ),
636
+            'phone'    => __( 'Phone', 'invoicing' ),
637
+            'company'  => __( 'Company', 'invoicing' ),
638
+            'company_id'  => __( 'Company ID', 'invoicing' ),
639
+            'invoices' => __( 'Invoices', 'invoicing' ),
640
+            'total_raw' => __( 'Total Spend', 'invoicing' ),
641
+            'signup'   => __( 'Date created', 'invoicing' ),
642
+        );
643 643
 
644
-		// Output the csv column headers.
645
-		fputcsv( $output, array_values( $columns ) );
644
+        // Output the csv column headers.
645
+        fputcsv( $output, array_values( $columns ) );
646 646
 
647
-		// Loop through
648
-		$table = new WPInv_Customers_Table();
649
-		foreach ( $customers as $customer_id ) {
647
+        // Loop through
648
+        $table = new WPInv_Customers_Table();
649
+        foreach ( $customers as $customer_id ) {
650 650
 
651
-			$user = get_user_by( 'id', $customer_id );
652
-			$row  = array();
653
-			if ( empty( $user ) ) {
654
-				continue;
655
-			}
651
+            $user = get_user_by( 'id', $customer_id );
652
+            $row  = array();
653
+            if ( empty( $user ) ) {
654
+                continue;
655
+            }
656 656
 
657
-			foreach ( array_keys( $columns ) as $column ) {
657
+            foreach ( array_keys( $columns ) as $column ) {
658 658
 
659
-				$method = 'column_' . $column;
659
+                $method = 'column_' . $column;
660 660
 
661
-				if ( 'name' == $column ) {
662
-					$value = esc_html( $user->display_name );
663
-				} else if( 'email' == $column ) {
664
-					$value = sanitize_email( $user->user_email );
665
-				} else if ( is_callable( array( $table, $method ) ) ) {
666
-					$value = strip_tags( $table->$method( $user ) );
667
-				}
661
+                if ( 'name' == $column ) {
662
+                    $value = esc_html( $user->display_name );
663
+                } else if( 'email' == $column ) {
664
+                    $value = sanitize_email( $user->user_email );
665
+                } else if ( is_callable( array( $table, $method ) ) ) {
666
+                    $value = strip_tags( $table->$method( $user ) );
667
+                }
668 668
 
669
-				if ( empty( $value ) ) {
670
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
671
-				}
669
+                if ( empty( $value ) ) {
670
+                    $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
671
+                }
672 672
 
673
-				$row[] = $value;
673
+                $row[] = $value;
674 674
 
675
-			}
675
+            }
676 676
 
677
-			fputcsv( $output, $row );
678
-		}
677
+            fputcsv( $output, $row );
678
+        }
679 679
 
680
-		fclose( $output );
681
-		exit;
680
+        fclose( $output );
681
+        exit;
682 682
 
683
-	}
683
+    }
684 684
 
685
-	/**
685
+    /**
686 686
      * Installs a plugin.
687
-	 *
688
-	 * @param array $data
687
+     *
688
+     * @param array $data
689 689
      */
690 690
     public function admin_install_plugin( $data ) {
691 691
 
692
-		if ( ! empty( $data['plugins'] ) ) {
693
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
694
-			wp_cache_flush();
692
+        if ( ! empty( $data['plugins'] ) ) {
693
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
694
+            wp_cache_flush();
695 695
 
696
-			foreach ( $data['plugins'] as $slug => $file ) {
697
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
698
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
699
-				$installed  = $upgrader->install( $plugin_zip );
696
+            foreach ( $data['plugins'] as $slug => $file ) {
697
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
698
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
699
+                $installed  = $upgrader->install( $plugin_zip );
700 700
 
701
-				if ( ! is_wp_error( $installed ) && $installed ) {
702
-					activate_plugin( $file, '', false, true );
703
-				} else {
704
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
705
-				}
701
+                if ( ! is_wp_error( $installed ) && $installed ) {
702
+                    activate_plugin( $file, '', false, true );
703
+                } else {
704
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
705
+                }
706 706
 
707
-			}
707
+            }
708 708
 
709
-		}
709
+        }
710 710
 
711
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
712
-		wp_safe_redirect( $redirect );
713
-		exit;
711
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
712
+        wp_safe_redirect( $redirect );
713
+        exit;
714 714
 
715
-	}
715
+    }
716 716
 
717
-	/**
717
+    /**
718 718
      * Connects a gateway.
719
-	 *
720
-	 * @param array $data
719
+     *
720
+     * @param array $data
721 721
      */
722 722
     public function admin_connect_gateway( $data ) {
723 723
 
724
-		if ( ! empty( $data['plugin'] ) ) {
724
+        if ( ! empty( $data['plugin'] ) ) {
725 725
 
726
-			$gateway     = sanitize_key( $data['plugin'] );
727
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
726
+            $gateway     = sanitize_key( $data['plugin'] );
727
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
728 728
 
729
-			if ( ! empty( $connect_url ) ) {
730
-				wp_redirect( $connect_url );
731
-				exit;
732
-			}
729
+            if ( ! empty( $connect_url ) ) {
730
+                wp_redirect( $connect_url );
731
+                exit;
732
+            }
733 733
 
734
-			if ( 'stripe' == $data['plugin'] ) {
735
-				require_once ABSPATH . 'wp-admin/includes/plugin.php';
736
-				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
737
-				wp_cache_flush();
734
+            if ( 'stripe' == $data['plugin'] ) {
735
+                require_once ABSPATH . 'wp-admin/includes/plugin.php';
736
+                include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
737
+                wp_cache_flush();
738 738
 
739
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
740
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
741
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
742
-					$upgrader->install( $plugin_zip );
743
-				}
739
+                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
740
+                    $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
741
+                    $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
742
+                    $upgrader->install( $plugin_zip );
743
+                }
744 744
 
745
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
746
-			}
745
+                activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
746
+            }
747 747
 
748
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
749
-			if ( ! empty( $connect_url ) ) {
750
-				wp_redirect( $connect_url );
751
-				exit;
752
-			}
748
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
749
+            if ( ! empty( $connect_url ) ) {
750
+                wp_redirect( $connect_url );
751
+                exit;
752
+            }
753 753
 
754
-		}
754
+        }
755 755
 
756
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
757
-		wp_safe_redirect( $redirect );
758
-		exit;
756
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
757
+        wp_safe_redirect( $redirect );
758
+        exit;
759 759
 
760
-	}
760
+    }
761 761
 
762
-	/**
762
+    /**
763 763
      * Recalculates discounts.
764
-	 * 
764
+     * 
765 765
      */
766 766
     public function admin_recalculate_discounts() {
767
-		global $wpdb;
767
+        global $wpdb;
768 768
 
769
-		// Fetch all invoices that have discount codes.
770
-		$table    = $wpdb->prefix . 'getpaid_invoices';
771
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
769
+        // Fetch all invoices that have discount codes.
770
+        $table    = $wpdb->prefix . 'getpaid_invoices';
771
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
772 772
 
773
-		foreach ( $invoices as $invoice ) {
773
+        foreach ( $invoices as $invoice ) {
774 774
 
775
-			$invoice = new WPInv_Invoice( $invoice );
775
+            $invoice = new WPInv_Invoice( $invoice );
776 776
 
777
-			if ( ! $invoice->exists() ) {
778
-				continue;
779
-			}
777
+            if ( ! $invoice->exists() ) {
778
+                continue;
779
+            }
780 780
 
781
-			// Abort if the discount does not exist or does not apply here.
782
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
783
-			if ( ! $discount->exists() ) {
784
-				continue;
785
-			}
781
+            // Abort if the discount does not exist or does not apply here.
782
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
783
+            if ( ! $discount->exists() ) {
784
+                continue;
785
+            }
786 786
 
787
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
788
-			$invoice->recalculate_total();
787
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
788
+            $invoice->recalculate_total();
789 789
 
790
-			if ( $invoice->get_total_discount() > 0 ) {
791
-				$invoice->save();
792
-			}
790
+            if ( $invoice->get_total_discount() > 0 ) {
791
+                $invoice->save();
792
+            }
793 793
 
794
-		}
794
+        }
795 795
 
796
-		// Show an admin message.
797
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
796
+        // Show an admin message.
797
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
798 798
 
799
-		// Redirect the admin.
800
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
801
-		exit;
799
+        // Redirect the admin.
800
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
801
+        exit;
802 802
 
803
-	}
803
+    }
804 804
 
805 805
     /**
806
-	 * Returns an array of admin notices.
807
-	 *
808
-	 * @since       1.0.19
806
+     * Returns an array of admin notices.
807
+     *
808
+     * @since       1.0.19
809 809
      * @return array
810
-	 */
811
-	public function get_notices() {
812
-		$notices = get_option( 'wpinv_admin_notices' );
810
+     */
811
+    public function get_notices() {
812
+        $notices = get_option( 'wpinv_admin_notices' );
813 813
         return is_array( $notices ) ? $notices : array();
814
-	}
814
+    }
815 815
 
816
-	/**
817
-	 * Checks if we have any admin notices.
818
-	 *
819
-	 * @since       2.0.4
816
+    /**
817
+     * Checks if we have any admin notices.
818
+     *
819
+     * @since       2.0.4
820 820
      * @return array
821
-	 */
822
-	public function has_notices() {
823
-		return count( $this->get_notices() ) > 0;
824
-	}
825
-
826
-	/**
827
-	 * Clears all admin notices
828
-	 *
829
-	 * @access      public
830
-	 * @since       1.0.19
831
-	 */
832
-	public function clear_notices() {
833
-		delete_option( 'wpinv_admin_notices' );
834
-	}
835
-
836
-	/**
837
-	 * Saves a new admin notice
838
-	 *
839
-	 * @access      public
840
-	 * @since       1.0.19
841
-	 */
842
-	public function save_notice( $type, $message ) {
843
-		$notices = $this->get_notices();
844
-
845
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
846
-			$notices[ $type ] = array();
847
-		}
848
-
849
-		$notices[ $type ][] = $message;
850
-
851
-		update_option( 'wpinv_admin_notices', $notices );
852
-	}
853
-
854
-	/**
855
-	 * Displays a success notice
856
-	 *
857
-	 * @param       string $msg The message to qeue.
858
-	 * @access      public
859
-	 * @since       1.0.19
860
-	 */
861
-	public function show_success( $msg ) {
862
-		$this->save_notice( 'success', $msg );
863
-	}
864
-
865
-	/**
866
-	 * Displays a error notice
867
-	 *
868
-	 * @access      public
869
-	 * @param       string $msg The message to qeue.
870
-	 * @since       1.0.19
871
-	 */
872
-	public function show_error( $msg ) {
873
-		$this->save_notice( 'error', $msg );
874
-	}
875
-
876
-	/**
877
-	 * Displays a warning notice
878
-	 *
879
-	 * @access      public
880
-	 * @param       string $msg The message to qeue.
881
-	 * @since       1.0.19
882
-	 */
883
-	public function show_warning( $msg ) {
884
-		$this->save_notice( 'warning', $msg );
885
-	}
886
-
887
-	/**
888
-	 * Displays a info notice
889
-	 *
890
-	 * @access      public
891
-	 * @param       string $msg The message to qeue.
892
-	 * @since       1.0.19
893
-	 */
894
-	public function show_info( $msg ) {
895
-		$this->save_notice( 'info', $msg );
896
-	}
897
-
898
-	/**
899
-	 * Show notices
900
-	 *
901
-	 * @access      public
902
-	 * @since       1.0.19
903
-	 */
904
-	public function show_notices() {
821
+     */
822
+    public function has_notices() {
823
+        return count( $this->get_notices() ) > 0;
824
+    }
825
+
826
+    /**
827
+     * Clears all admin notices
828
+     *
829
+     * @access      public
830
+     * @since       1.0.19
831
+     */
832
+    public function clear_notices() {
833
+        delete_option( 'wpinv_admin_notices' );
834
+    }
835
+
836
+    /**
837
+     * Saves a new admin notice
838
+     *
839
+     * @access      public
840
+     * @since       1.0.19
841
+     */
842
+    public function save_notice( $type, $message ) {
843
+        $notices = $this->get_notices();
844
+
845
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
846
+            $notices[ $type ] = array();
847
+        }
848
+
849
+        $notices[ $type ][] = $message;
850
+
851
+        update_option( 'wpinv_admin_notices', $notices );
852
+    }
853
+
854
+    /**
855
+     * Displays a success notice
856
+     *
857
+     * @param       string $msg The message to qeue.
858
+     * @access      public
859
+     * @since       1.0.19
860
+     */
861
+    public function show_success( $msg ) {
862
+        $this->save_notice( 'success', $msg );
863
+    }
864
+
865
+    /**
866
+     * Displays a error notice
867
+     *
868
+     * @access      public
869
+     * @param       string $msg The message to qeue.
870
+     * @since       1.0.19
871
+     */
872
+    public function show_error( $msg ) {
873
+        $this->save_notice( 'error', $msg );
874
+    }
875
+
876
+    /**
877
+     * Displays a warning notice
878
+     *
879
+     * @access      public
880
+     * @param       string $msg The message to qeue.
881
+     * @since       1.0.19
882
+     */
883
+    public function show_warning( $msg ) {
884
+        $this->save_notice( 'warning', $msg );
885
+    }
886
+
887
+    /**
888
+     * Displays a info notice
889
+     *
890
+     * @access      public
891
+     * @param       string $msg The message to qeue.
892
+     * @since       1.0.19
893
+     */
894
+    public function show_info( $msg ) {
895
+        $this->save_notice( 'info', $msg );
896
+    }
897
+
898
+    /**
899
+     * Show notices
900
+     *
901
+     * @access      public
902
+     * @since       1.0.19
903
+     */
904
+    public function show_notices() {
905 905
 
906 906
         $notices = $this->get_notices();
907 907
         $this->clear_notices();
908 908
 
909
-		foreach ( $notices as $type => $messages ) {
909
+        foreach ( $notices as $type => $messages ) {
910 910
 
911
-			if ( ! is_array( $messages ) ) {
912
-				continue;
913
-			}
911
+            if ( ! is_array( $messages ) ) {
912
+                continue;
913
+            }
914 914
 
915 915
             $type  = sanitize_key( $type );
916
-			foreach ( $messages as $message ) {
916
+            foreach ( $messages as $message ) {
917 917
                 $message = wp_kses_post( $message );
918
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
918
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
919 919
             }
920 920
 
921 921
         }
922 922
 
923
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
924
-
925
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
926
-				$url     = wp_nonce_url(
927
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
928
-					'getpaid-nonce',
929
-					'getpaid-nonce'
930
-				);
931
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
932
-				$message2 = __( 'Generate Pages', 'invoicing' );
933
-				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
934
-				break;
935
-			}
923
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
924
+
925
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
926
+                $url     = wp_nonce_url(
927
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
928
+                    'getpaid-nonce',
929
+                    'getpaid-nonce'
930
+                );
931
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
932
+                $message2 = __( 'Generate Pages', 'invoicing' );
933
+                echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
934
+                break;
935
+            }
936 936
 
937
-		}
937
+        }
938 938
 
939
-	}
939
+    }
940 940
 
941 941
 }
Please login to merge, or discard this patch.
Spacing   +280 added lines, -280 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
  * The main admin class.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,33 +54,33 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
68
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9);
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page'));
64
+		add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form'));
65
+		add_action('getpaid_authenticated_admin_action_duplicate_invoice', array($this, 'duplicate_invoice'));
66
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
67
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
68
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
69
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
70
+		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables'));
71
+		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices'));
72
+		add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers'));
73
+		add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts'));
74
+		add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin'));
75
+		add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway'));
76
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
77
+		do_action('getpaid_init_admin_hooks', $this);
78 78
 
79 79
 		// Setup/welcome
80
-		if ( ! empty( $_GET['page'] ) ) {
81
-			switch ( $_GET['page'] ) {
80
+		if (!empty($_GET['page'])) {
81
+			switch ($_GET['page']) {
82 82
 				case 'gp-setup' :
83
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
83
+					include_once(dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php');
84 84
 					break;
85 85
 			}
86 86
 		}
@@ -94,37 +94,37 @@  discard block
 block discarded – undo
94 94
 	public function enqeue_scripts() {
95 95
         global $current_screen, $pagenow;
96 96
 
97
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
97
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
98 98
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
99 99
 
100
-        if ( ! empty( $current_screen->post_type ) ) {
100
+        if (!empty($current_screen->post_type)) {
101 101
 			$page = $current_screen->post_type;
102 102
         }
103 103
 
104 104
         // General styles.
105
-        if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page ) {
105
+        if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page) {
106 106
 
107 107
             // Styles.
108
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
109
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
110
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
108
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
109
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
110
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
111 111
 
112 112
             // Scripts.
113
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
113
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
114 114
 
115
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
116
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ),  $version );
117
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
115
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
116
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version);
117
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
118 118
 
119 119
         }
120 120
 
121 121
         // Payment form scripts.
122
-		if ( 'wpi_payment_form' == $page && $editing ) {
122
+		if ('wpi_payment_form' == $page && $editing) {
123 123
             $this->load_payment_form_scripts();
124 124
         }
125 125
 
126
-		if ( $page == 'wpinv-subscriptions' ) {
127
-			wp_enqueue_script( 'postbox' );
126
+		if ($page == 'wpinv-subscriptions') {
127
+			wp_enqueue_script('postbox');
128 128
 		}
129 129
 
130 130
     }
@@ -137,32 +137,32 @@  discard block
 block discarded – undo
137 137
         global $post;
138 138
 
139 139
 		$date_range = array(
140
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
140
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
141 141
 		);
142 142
 
143
-		if ( $date_range['period'] == 'custom' ) {
143
+		if ($date_range['period'] == 'custom') {
144 144
 			
145
-			if ( isset( $_GET['from'] ) ) {
146
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
145
+			if (isset($_GET['from'])) {
146
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
147 147
 			}
148 148
 
149
-			if ( isset( $_GET['to'] ) ) {
150
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
149
+			if (isset($_GET['to'])) {
150
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
151 151
 			}
152 152
 
153 153
 		}
154 154
 
155 155
         $i18n = array(
156
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
157
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
158
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
159
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
160
-			'rest_root'                 => esc_url_raw( rest_url() ),
156
+            'ajax_url'                  => admin_url('admin-ajax.php'),
157
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
158
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
159
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
160
+			'rest_root'                 => esc_url_raw(rest_url()),
161 161
 			'date_range'                => $date_range,
162
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
163
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
164
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
165
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
162
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
163
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
164
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
165
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
166 166
             'tax'                       => wpinv_tax_amount(),
167 167
             'discount'                  => 0,
168 168
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -171,38 +171,38 @@  discard block
 block discarded – undo
171 171
             'thousand_sep'              => wpinv_thousands_separator(),
172 172
             'decimal_sep'               => wpinv_decimal_separator(),
173 173
             'decimals'                  => wpinv_decimals(),
174
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
175
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
176
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
177
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
178
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
179
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
180
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
181
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
182
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
183
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
184
-            'action_edit'               => __( 'Edit', 'invoicing' ),
185
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
186
-            'item_description'          => __( 'Item Description', 'invoicing' ),
187
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
188
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
189
-			'searching'                 => __( 'Searching', 'invoicing' ),
190
-			'loading'                   => __( 'Loading...', 'invoicing' ),
191
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
192
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
174
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
175
+            'status_publish'            => wpinv_status_nicename('publish'),
176
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
177
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
178
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
179
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
180
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
181
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
182
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
183
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
184
+            'action_edit'               => __('Edit', 'invoicing'),
185
+            'action_cancel'             => __('Cancel', 'invoicing'),
186
+            'item_description'          => __('Item Description', 'invoicing'),
187
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
188
+            'discount_description'      => __('Discount Description', 'invoicing'),
189
+			'searching'                 => __('Searching', 'invoicing'),
190
+			'loading'                   => __('Loading...', 'invoicing'),
191
+			'search_customers'          => __('Enter customer name or email', 'invoicing'),
192
+			'search_items'              => __('Enter item name', 'invoicing'),
193 193
         );
194 194
 
195
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
195
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
196 196
 
197
-			$invoice              = new WPInv_Invoice( $post );
197
+			$invoice              = new WPInv_Invoice($post);
198 198
 			$i18n['save_invoice'] = sprintf(
199
-				__( 'Save %s', 'invoicing' ),
200
-				ucfirst( $invoice->get_invoice_quote_type() )
199
+				__('Save %s', 'invoicing'),
200
+				ucfirst($invoice->get_invoice_quote_type())
201 201
 			);
202 202
 
203 203
 			$i18n['invoice_description'] = sprintf(
204
-				__( '%s Description', 'invoicing' ),
205
-				ucfirst( $invoice->get_invoice_quote_type() )
204
+				__('%s Description', 'invoicing'),
205
+				ucfirst($invoice->get_invoice_quote_type())
206 206
 			);
207 207
 
208 208
 		}
@@ -216,24 +216,24 @@  discard block
 block discarded – undo
216 216
 	 * @param  string $footer_text
217 217
 	 * @return string
218 218
 	 */
219
-	public function admin_footer_text( $footer_text ) {
219
+	public function admin_footer_text($footer_text) {
220 220
 		global $current_screen;
221 221
 
222
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
222
+		$page = isset($_GET['page']) ? $_GET['page'] : '';
223 223
 
224
-        if ( ! empty( $current_screen->post_type ) ) {
224
+        if (!empty($current_screen->post_type)) {
225 225
 			$page = $current_screen->post_type;
226 226
         }
227 227
 
228 228
         // General styles.
229
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
229
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
230 230
 
231 231
 			// Change the footer text
232
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
232
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
233 233
 
234
-				$rating_url  = esc_url(
234
+				$rating_url = esc_url(
235 235
 					wp_nonce_url(
236
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
236
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
237 237
 						'getpaid-nonce',
238 238
 						'getpaid-nonce'
239 239
 						)
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
 				$footer_text = sprintf(
243 243
 					/* translators: %s: five stars */
244
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
244
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
245 245
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246 246
 				);
247 247
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 				$footer_text = sprintf(
251 251
 					/* translators: %s: GetPaid */
252
-					__( 'Thank you for using %s!', 'invoicing' ),
252
+					__('Thank you for using %s!', 'invoicing'),
253 253
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254 254
 				);
255 255
 
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 * @since  2.0.0
267 267
 	 */
268 268
 	public function redirect_to_wordpress_rating_page() {
269
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
270
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
269
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
270
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
271 271
 		exit;
272 272
 	}
273 273
 
@@ -278,30 +278,30 @@  discard block
 block discarded – undo
278 278
 	protected function load_payment_form_scripts() {
279 279
         global $post;
280 280
 
281
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
282
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
283
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
281
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION);
282
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
283
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
284 284
 
285
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
286
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ),  $version );
285
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
286
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), $version);
287 287
 
288 288
 		wp_localize_script(
289 289
             'wpinv-admin-payment-form-script',
290 290
             'wpinvPaymentFormAdmin',
291 291
             array(
292
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
293
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
292
+				'elements'      => wpinv_get_data('payment-form-elements'),
293
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
294 294
 				'currency'      => wpinv_currency_symbol(),
295 295
 				'position'      => wpinv_currency_position(),
296 296
 				'decimals'      => (int) wpinv_decimals(),
297 297
 				'thousands_sep' => wpinv_thousands_separator(),
298 298
 				'decimals_sep'  => wpinv_decimal_separator(),
299
-				'form_items'    => gepaid_get_form_items( $post->ID ),
299
+				'form_items'    => gepaid_get_form_items($post->ID),
300 300
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
301 301
             )
302 302
         );
303 303
 
304
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
304
+        wp_enqueue_script('wpinv-admin-payment-form-script');
305 305
 
306 306
     }
307 307
 
@@ -312,25 +312,25 @@  discard block
 block discarded – undo
312 312
      * @return string
313 313
 	 *
314 314
 	 */
315
-    public function admin_body_class( $classes ) {
315
+    public function admin_body_class($classes) {
316 316
 		global $pagenow, $post, $current_screen;
317 317
 
318 318
 
319
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
319
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
320 320
 
321
-        if ( ! empty( $current_screen->post_type ) ) {
321
+        if (!empty($current_screen->post_type)) {
322 322
 			$page = $current_screen->post_type;
323 323
         }
324 324
 
325
-        if ( false !== stripos( $page, 'wpi' ) ) {
326
-            $classes .= ' wpi-' . sanitize_key( $page );
325
+        if (false !== stripos($page, 'wpi')) {
326
+            $classes .= ' wpi-' . sanitize_key($page);
327 327
         }
328 328
 
329
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
329
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
330 330
             $classes .= ' wpinv-cpt wpinv';
331 331
 		}
332 332
 		
333
-		if ( getpaid_is_invoice_post_type( $page ) ) {
333
+		if (getpaid_is_invoice_post_type($page)) {
334 334
             $classes .= ' getpaid-is-invoice-cpt';
335 335
         }
336 336
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     /**
341 341
 	 * Maybe show the AyeCode Connect Notice.
342 342
 	 */
343
-	public function init_ayecode_connect_helper(){
343
+	public function init_ayecode_connect_helper() {
344 344
 
345 345
 		// Register with the deactivation survey class.
346 346
 		AyeCode_Deactivation_Survey::instance(array(
@@ -348,20 +348,20 @@  discard block
 block discarded – undo
348 348
 			'version'	        => WPINV_VERSION,
349 349
 			'support_url'       => 'https://wpgetpaid.com/support/',
350 350
 			'documentation_url' => 'https://docs.wpgetpaid.com/',
351
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
351
+			'activated'         => (int) get_option('gepaid_installed_on'),
352 352
 		));
353 353
 
354 354
         new AyeCode_Connect_Helper(
355 355
             array(
356
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
357
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
358
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
359
-				'connect_button'    => __("Connect Site","invoicing"),
360
-				'connecting_button'    => __("Connecting...","invoicing"),
361
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
362
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
356
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
357
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
358
+				'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
359
+				'connect_button'    => __("Connect Site", "invoicing"),
360
+				'connecting_button'    => __("Connecting...", "invoicing"),
361
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
362
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
363 363
             ),
364
-            array( 'wpi-addons' )
364
+            array('wpi-addons')
365 365
         );
366 366
 
367 367
     }
@@ -373,20 +373,20 @@  discard block
 block discarded – undo
373 373
 	 */
374 374
 	public function activation_redirect() {
375 375
 
376
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
376
+		$redirected = get_option('wpinv_redirected_to_settings');
377 377
 
378
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
378
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
379 379
 			return;
380 380
 		}
381 381
 
382 382
 		// Bail if activating from network, or bulk
383
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
383
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
384 384
 			return;
385 385
 		}
386 386
 
387
-	    update_option( 'wpinv_redirected_to_settings', 1 );
387
+	    update_option('wpinv_redirected_to_settings', 1);
388 388
 
389
-        wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
389
+        wp_safe_redirect(admin_url('index.php?page=gp-setup'));
390 390
         exit;
391 391
 
392 392
 	}
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
      */
397 397
     public function maybe_do_admin_action() {
398 398
 
399
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
400
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
401
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
399
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
400
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
401
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
402 402
         }
403 403
 
404 404
     }
@@ -408,24 +408,24 @@  discard block
 block discarded – undo
408 408
 	 * 
409 409
 	 * @param array $args
410 410
      */
411
-    public function duplicate_invoice( $args ) {
411
+    public function duplicate_invoice($args) {
412 412
 
413
-		if ( empty( $args['invoice_id'] ) ) {
413
+		if (empty($args['invoice_id'])) {
414 414
 			return;
415 415
 		}
416 416
 
417
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
417
+		$invoice = new WPInv_Invoice((int) $args['invoice_id']);
418 418
 
419
-		if ( ! $invoice->exists() ) {
419
+		if (!$invoice->exists()) {
420 420
 			return;
421 421
 		}
422 422
 
423
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
423
+		$new_invoice = getpaid_duplicate_invoice($invoice);
424 424
 		$new_invoice->save();
425 425
 
426
-		if ( $new_invoice->exists() ) {
426
+		if ($new_invoice->exists()) {
427 427
 
428
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
428
+			getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'newsletter-optin-box'));
429 429
 
430 430
 			wp_safe_redirect(
431 431
 				add_query_arg(
@@ -433,14 +433,14 @@  discard block
 block discarded – undo
433 433
 						'action' => 'edit',
434 434
 						'post' => $new_invoice->get_id(),
435 435
 					),
436
-					admin_url( 'post.php' )
436
+					admin_url('post.php')
437 437
 				)
438 438
 			);
439 439
 			exit;
440 440
 
441 441
 		}
442 442
 
443
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
443
+		getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box'));
444 444
 
445 445
 	}
446 446
 
@@ -449,34 +449,34 @@  discard block
 block discarded – undo
449 449
 	 * 
450 450
 	 * @param array $args
451 451
      */
452
-    public function duplicate_payment_form( $args ) {
452
+    public function duplicate_payment_form($args) {
453 453
 
454
-		if ( empty( $args['form_id'] ) ) {
454
+		if (empty($args['form_id'])) {
455 455
 			return;
456 456
 		}
457 457
 
458
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
458
+		$form = new GetPaid_Payment_Form((int) $args['form_id']);
459 459
 
460
-		if ( ! $form->exists() ) {
460
+		if (!$form->exists()) {
461 461
 			return;
462 462
 		}
463 463
 
464 464
 		$new_form = new GetPaid_Payment_Form();
465
-		$new_form->set_author( $form->get_author( 'edit' ) );
466
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
467
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
468
-		$new_form->set_items( $form->get_items( 'edit' ) );
465
+		$new_form->set_author($form->get_author('edit'));
466
+		$new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing'));
467
+		$new_form->set_elements($form->get_elements('edit'));
468
+		$new_form->set_items($form->get_items('edit'));
469 469
 		$new_form->save();
470 470
 
471
-		if ( $new_form->exists() ) {
472
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
473
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
471
+		if ($new_form->exists()) {
472
+			$this->show_success(__('Form duplicated successfully', 'invoicing'));
473
+			$url = get_edit_post_link($new_form->get_id(), 'edit');
474 474
 		} else {
475
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
475
+			$this->show_error(__('Unable to duplicate form', 'invoicing'));
476
+			$url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'));
477 477
 		}
478 478
 
479
-		wp_redirect( $url );
479
+		wp_redirect($url);
480 480
 		exit;
481 481
 	}
482 482
 
@@ -485,16 +485,16 @@  discard block
 block discarded – undo
485 485
 	 * 
486 486
 	 * @param array $args
487 487
      */
488
-    public function send_customer_invoice( $args ) {
489
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
488
+    public function send_customer_invoice($args) {
489
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true);
490 490
 
491
-		if ( $sent ) {
492
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
491
+		if ($sent) {
492
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
493 493
 		} else {
494
-			$this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
494
+			$this->show_error(__('Could not send the invoice to the customer', 'invoicing'));
495 495
 		}
496 496
 
497
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
497
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
498 498
 		exit;
499 499
 	}
500 500
 
@@ -503,16 +503,16 @@  discard block
 block discarded – undo
503 503
 	 * 
504 504
 	 * @param array $args
505 505
      */
506
-    public function send_customer_payment_reminder( $args ) {
507
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
506
+    public function send_customer_payment_reminder($args) {
507
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
508 508
 
509
-		if ( $sent ) {
510
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
509
+		if ($sent) {
510
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
511 511
 		} else {
512
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
512
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
513 513
 		}
514 514
 
515
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
515
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
516 516
 		exit;
517 517
 	}
518 518
 
@@ -522,8 +522,8 @@  discard block
 block discarded – undo
522 522
      */
523 523
     public function admin_reset_tax_rates() {
524 524
 
525
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
526
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
525
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
526
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
527 527
 		exit;
528 528
 
529 529
 	}
@@ -535,8 +535,8 @@  discard block
 block discarded – undo
535 535
     public function admin_create_missing_pages() {
536 536
 		$installer = new GetPaid_Installer();
537 537
 		$installer->create_pages();
538
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
539
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
538
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
539
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
540 540
 		exit;
541 541
 	}
542 542
 
@@ -548,35 +548,35 @@  discard block
 block discarded – undo
548 548
 		global $wpdb;
549 549
 		$installer = new GetPaid_Installer();
550 550
 
551
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
551
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
552 552
 			$installer->create_subscriptions_table();
553 553
 
554
-			if ( $wpdb->last_error !== '' ) {
555
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
554
+			if ($wpdb->last_error !== '') {
555
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
556 556
 			}
557 557
 		}
558 558
 
559
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
559
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
560 560
 			$installer->create_invoices_table();
561 561
 
562
-			if ( $wpdb->last_error !== '' ) {
563
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
562
+			if ($wpdb->last_error !== '') {
563
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
564 564
 			}
565 565
 		}
566 566
 
567
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
567
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
568 568
 			$installer->create_invoice_items_table();
569 569
 
570
-			if ( $wpdb->last_error !== '' ) {
571
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
570
+			if ($wpdb->last_error !== '') {
571
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
572 572
 			}
573 573
 		}
574 574
 
575
-		if ( ! $this->has_notices() ) {
576
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
575
+		if (!$this->has_notices()) {
576
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
577 577
 		}
578 578
 
579
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
579
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
580 580
 		exit;
581 581
 	}
582 582
 
@@ -591,10 +591,10 @@  discard block
 block discarded – undo
591 591
 		$installer->migrate_old_invoices();
592 592
 
593 593
 		// Show an admin message.
594
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
594
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
595 595
 
596 596
 		// Redirect the admin.
597
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
597
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
598 598
 		exit;
599 599
 
600 600
 	}
@@ -606,18 +606,18 @@  discard block
 block discarded – undo
606 606
     public function admin_download_customers() {
607 607
 		global $wpdb;
608 608
 
609
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
609
+		$output = fopen('php://output', 'w') or die(__('Unsupported server', 'invoicing'));
610 610
 
611
-		header( "Content-Type:text/csv" );
612
-		header( "Content-Disposition:attachment;filename=customers.csv" );
611
+		header("Content-Type:text/csv");
612
+		header("Content-Disposition:attachment;filename=customers.csv");
613 613
 
614 614
 		$post_types = '';
615 615
 
616
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
617
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
616
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
617
+			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type);
618 618
 		}
619 619
 
620
-		$post_types = rtrim( $post_types, ' OR' );
620
+		$post_types = rtrim($post_types, ' OR');
621 621
 
622 622
 		$customers = $wpdb->get_col(
623 623
 			$wpdb->prepare(
@@ -626,58 +626,58 @@  discard block
 block discarded – undo
626 626
 		);
627 627
 
628 628
 		$columns = array(
629
-			'name'     => __( 'Name', 'invoicing' ),
630
-			'email'    => __( 'Email', 'invoicing' ),
631
-			'country'  => __( 'Country', 'invoicing' ),
632
-			'state'    => __( 'State', 'invoicing' ),
633
-			'city'     => __( 'City', 'invoicing' ),
634
-			'zip'      => __( 'ZIP', 'invoicing' ),
635
-			'address'  => __( 'Address', 'invoicing' ),
636
-			'phone'    => __( 'Phone', 'invoicing' ),
637
-			'company'  => __( 'Company', 'invoicing' ),
638
-			'company_id'  => __( 'Company ID', 'invoicing' ),
639
-			'invoices' => __( 'Invoices', 'invoicing' ),
640
-			'total_raw' => __( 'Total Spend', 'invoicing' ),
641
-			'signup'   => __( 'Date created', 'invoicing' ),
629
+			'name'     => __('Name', 'invoicing'),
630
+			'email'    => __('Email', 'invoicing'),
631
+			'country'  => __('Country', 'invoicing'),
632
+			'state'    => __('State', 'invoicing'),
633
+			'city'     => __('City', 'invoicing'),
634
+			'zip'      => __('ZIP', 'invoicing'),
635
+			'address'  => __('Address', 'invoicing'),
636
+			'phone'    => __('Phone', 'invoicing'),
637
+			'company'  => __('Company', 'invoicing'),
638
+			'company_id'  => __('Company ID', 'invoicing'),
639
+			'invoices' => __('Invoices', 'invoicing'),
640
+			'total_raw' => __('Total Spend', 'invoicing'),
641
+			'signup'   => __('Date created', 'invoicing'),
642 642
 		);
643 643
 
644 644
 		// Output the csv column headers.
645
-		fputcsv( $output, array_values( $columns ) );
645
+		fputcsv($output, array_values($columns));
646 646
 
647 647
 		// Loop through
648 648
 		$table = new WPInv_Customers_Table();
649
-		foreach ( $customers as $customer_id ) {
649
+		foreach ($customers as $customer_id) {
650 650
 
651
-			$user = get_user_by( 'id', $customer_id );
651
+			$user = get_user_by('id', $customer_id);
652 652
 			$row  = array();
653
-			if ( empty( $user ) ) {
653
+			if (empty($user)) {
654 654
 				continue;
655 655
 			}
656 656
 
657
-			foreach ( array_keys( $columns ) as $column ) {
657
+			foreach (array_keys($columns) as $column) {
658 658
 
659 659
 				$method = 'column_' . $column;
660 660
 
661
-				if ( 'name' == $column ) {
662
-					$value = esc_html( $user->display_name );
663
-				} else if( 'email' == $column ) {
664
-					$value = sanitize_email( $user->user_email );
665
-				} else if ( is_callable( array( $table, $method ) ) ) {
666
-					$value = strip_tags( $table->$method( $user ) );
661
+				if ('name' == $column) {
662
+					$value = esc_html($user->display_name);
663
+				} else if ('email' == $column) {
664
+					$value = sanitize_email($user->user_email);
665
+				} else if (is_callable(array($table, $method))) {
666
+					$value = strip_tags($table->$method($user));
667 667
 				}
668 668
 
669
-				if ( empty( $value ) ) {
670
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
669
+				if (empty($value)) {
670
+					$value = esc_html(get_user_meta($user->ID, '_wpinv_' . $column, true));
671 671
 				}
672 672
 
673 673
 				$row[] = $value;
674 674
 
675 675
 			}
676 676
 
677
-			fputcsv( $output, $row );
677
+			fputcsv($output, $row);
678 678
 		}
679 679
 
680
-		fclose( $output );
680
+		fclose($output);
681 681
 		exit;
682 682
 
683 683
 	}
@@ -687,29 +687,29 @@  discard block
 block discarded – undo
687 687
 	 *
688 688
 	 * @param array $data
689 689
      */
690
-    public function admin_install_plugin( $data ) {
690
+    public function admin_install_plugin($data) {
691 691
 
692
-		if ( ! empty( $data['plugins'] ) ) {
692
+		if (!empty($data['plugins'])) {
693 693
 			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
694 694
 			wp_cache_flush();
695 695
 
696
-			foreach ( $data['plugins'] as $slug => $file ) {
697
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
698
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
699
-				$installed  = $upgrader->install( $plugin_zip );
696
+			foreach ($data['plugins'] as $slug => $file) {
697
+				$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip');
698
+				$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
699
+				$installed  = $upgrader->install($plugin_zip);
700 700
 
701
-				if ( ! is_wp_error( $installed ) && $installed ) {
702
-					activate_plugin( $file, '', false, true );
701
+				if (!is_wp_error($installed) && $installed) {
702
+					activate_plugin($file, '', false, true);
703 703
 				} else {
704
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
704
+					wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);
705 705
 				}
706 706
 
707 707
 			}
708 708
 
709 709
 		}
710 710
 
711
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
712
-		wp_safe_redirect( $redirect );
711
+		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php');
712
+		wp_safe_redirect($redirect);
713 713
 		exit;
714 714
 
715 715
 	}
@@ -719,42 +719,42 @@  discard block
 block discarded – undo
719 719
 	 *
720 720
 	 * @param array $data
721 721
      */
722
-    public function admin_connect_gateway( $data ) {
722
+    public function admin_connect_gateway($data) {
723 723
 
724
-		if ( ! empty( $data['plugin'] ) ) {
724
+		if (!empty($data['plugin'])) {
725 725
 
726
-			$gateway     = sanitize_key( $data['plugin'] );
727
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
726
+			$gateway     = sanitize_key($data['plugin']);
727
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
728 728
 
729
-			if ( ! empty( $connect_url ) ) {
730
-				wp_redirect( $connect_url );
729
+			if (!empty($connect_url)) {
730
+				wp_redirect($connect_url);
731 731
 				exit;
732 732
 			}
733 733
 
734
-			if ( 'stripe' == $data['plugin'] ) {
734
+			if ('stripe' == $data['plugin']) {
735 735
 				require_once ABSPATH . 'wp-admin/includes/plugin.php';
736 736
 				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
737 737
 				wp_cache_flush();
738 738
 
739
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
740
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
741
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
742
-					$upgrader->install( $plugin_zip );
739
+				if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) {
740
+					$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip');
741
+					$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
742
+					$upgrader->install($plugin_zip);
743 743
 				}
744 744
 
745
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
745
+				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true);
746 746
 			}
747 747
 
748
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
749
-			if ( ! empty( $connect_url ) ) {
750
-				wp_redirect( $connect_url );
748
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
749
+			if (!empty($connect_url)) {
750
+				wp_redirect($connect_url);
751 751
 				exit;
752 752
 			}
753 753
 
754 754
 		}
755 755
 
756
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
757
-		wp_safe_redirect( $redirect );
756
+		$redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways');
757
+		wp_safe_redirect($redirect);
758 758
 		exit;
759 759
 
760 760
 	}
@@ -768,36 +768,36 @@  discard block
 block discarded – undo
768 768
 
769 769
 		// Fetch all invoices that have discount codes.
770 770
 		$table    = $wpdb->prefix . 'getpaid_invoices';
771
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
771
+		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''");
772 772
 
773
-		foreach ( $invoices as $invoice ) {
773
+		foreach ($invoices as $invoice) {
774 774
 
775
-			$invoice = new WPInv_Invoice( $invoice );
775
+			$invoice = new WPInv_Invoice($invoice);
776 776
 
777
-			if ( ! $invoice->exists() ) {
777
+			if (!$invoice->exists()) {
778 778
 				continue;
779 779
 			}
780 780
 
781 781
 			// Abort if the discount does not exist or does not apply here.
782
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
783
-			if ( ! $discount->exists() ) {
782
+			$discount = new WPInv_Discount($invoice->get_discount_code());
783
+			if (!$discount->exists()) {
784 784
 				continue;
785 785
 			}
786 786
 
787
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
787
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
788 788
 			$invoice->recalculate_total();
789 789
 
790
-			if ( $invoice->get_total_discount() > 0 ) {
790
+			if ($invoice->get_total_discount() > 0) {
791 791
 				$invoice->save();
792 792
 			}
793 793
 
794 794
 		}
795 795
 
796 796
 		// Show an admin message.
797
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
797
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
798 798
 
799 799
 		// Redirect the admin.
800
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
800
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
801 801
 		exit;
802 802
 
803 803
 	}
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
      * @return array
810 810
 	 */
811 811
 	public function get_notices() {
812
-		$notices = get_option( 'wpinv_admin_notices' );
813
-        return is_array( $notices ) ? $notices : array();
812
+		$notices = get_option('wpinv_admin_notices');
813
+        return is_array($notices) ? $notices : array();
814 814
 	}
815 815
 
816 816
 	/**
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
      * @return array
821 821
 	 */
822 822
 	public function has_notices() {
823
-		return count( $this->get_notices() ) > 0;
823
+		return count($this->get_notices()) > 0;
824 824
 	}
825 825
 
826 826
 	/**
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 	 * @since       1.0.19
831 831
 	 */
832 832
 	public function clear_notices() {
833
-		delete_option( 'wpinv_admin_notices' );
833
+		delete_option('wpinv_admin_notices');
834 834
 	}
835 835
 
836 836
 	/**
@@ -839,16 +839,16 @@  discard block
 block discarded – undo
839 839
 	 * @access      public
840 840
 	 * @since       1.0.19
841 841
 	 */
842
-	public function save_notice( $type, $message ) {
842
+	public function save_notice($type, $message) {
843 843
 		$notices = $this->get_notices();
844 844
 
845
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
846
-			$notices[ $type ] = array();
845
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
846
+			$notices[$type] = array();
847 847
 		}
848 848
 
849
-		$notices[ $type ][] = $message;
849
+		$notices[$type][] = $message;
850 850
 
851
-		update_option( 'wpinv_admin_notices', $notices );
851
+		update_option('wpinv_admin_notices', $notices);
852 852
 	}
853 853
 
854 854
 	/**
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	 * @access      public
859 859
 	 * @since       1.0.19
860 860
 	 */
861
-	public function show_success( $msg ) {
862
-		$this->save_notice( 'success', $msg );
861
+	public function show_success($msg) {
862
+		$this->save_notice('success', $msg);
863 863
 	}
864 864
 
865 865
 	/**
@@ -869,8 +869,8 @@  discard block
 block discarded – undo
869 869
 	 * @param       string $msg The message to qeue.
870 870
 	 * @since       1.0.19
871 871
 	 */
872
-	public function show_error( $msg ) {
873
-		$this->save_notice( 'error', $msg );
872
+	public function show_error($msg) {
873
+		$this->save_notice('error', $msg);
874 874
 	}
875 875
 
876 876
 	/**
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
 	 * @param       string $msg The message to qeue.
881 881
 	 * @since       1.0.19
882 882
 	 */
883
-	public function show_warning( $msg ) {
884
-		$this->save_notice( 'warning', $msg );
883
+	public function show_warning($msg) {
884
+		$this->save_notice('warning', $msg);
885 885
 	}
886 886
 
887 887
 	/**
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	 * @param       string $msg The message to qeue.
892 892
 	 * @since       1.0.19
893 893
 	 */
894
-	public function show_info( $msg ) {
895
-		$this->save_notice( 'info', $msg );
894
+	public function show_info($msg) {
895
+		$this->save_notice('info', $msg);
896 896
 	}
897 897
 
898 898
 	/**
@@ -906,30 +906,30 @@  discard block
 block discarded – undo
906 906
         $notices = $this->get_notices();
907 907
         $this->clear_notices();
908 908
 
909
-		foreach ( $notices as $type => $messages ) {
909
+		foreach ($notices as $type => $messages) {
910 910
 
911
-			if ( ! is_array( $messages ) ) {
911
+			if (!is_array($messages)) {
912 912
 				continue;
913 913
 			}
914 914
 
915
-            $type  = sanitize_key( $type );
916
-			foreach ( $messages as $message ) {
917
-                $message = wp_kses_post( $message );
915
+            $type = sanitize_key($type);
916
+			foreach ($messages as $message) {
917
+                $message = wp_kses_post($message);
918 918
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
919 919
             }
920 920
 
921 921
         }
922 922
 
923
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
923
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
924 924
 
925
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
926
-				$url     = wp_nonce_url(
927
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
925
+			if (!is_numeric(wpinv_get_option($page, false))) {
926
+				$url = wp_nonce_url(
927
+					add_query_arg('getpaid-admin-action', 'create_missing_pages'),
928 928
 					'getpaid-nonce',
929 929
 					'getpaid-nonce'
930 930
 				);
931
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
932
-				$message2 = __( 'Generate Pages', 'invoicing' );
931
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
932
+				$message2 = __('Generate Pages', 'invoicing');
933 933
 				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
934 934
 				break;
935 935
 			}
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-helper.php 2 patches
Indentation   +392 added lines, -392 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,395 +11,395 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Helper {
13 13
 
14
-	/**
15
-	 * A component helper for generating a input name.
16
-	 *
17
-	 * @param $text
18
-	 * @param $multiple bool If the name is set to be multiple but no brackets found then we add some.
19
-	 *
20
-	 * @return string
21
-	 */
22
-	public static function name( $text, $multiple = false ) {
23
-		$output = '';
24
-
25
-		if ( $text ) {
26
-			$is_multiple = strpos( $text, '[' ) === false && $multiple ? '[]' : '';
27
-			$output      = ' name="' . esc_attr( $text ) . $is_multiple . '" ';
28
-		}
29
-
30
-		return $output;
31
-	}
32
-
33
-	/**
34
-	 * A component helper for generating a item id.
35
-	 *
36
-	 * @param $text string The text to be used as the value.
37
-	 *
38
-	 * @return string The sanitized item.
39
-	 */
40
-	public static function id( $text ) {
41
-		$output = '';
42
-
43
-		if ( $text ) {
44
-			$output = ' id="' . sanitize_html_class( $text ) . '" ';
45
-		}
46
-
47
-		return $output;
48
-	}
49
-
50
-	/**
51
-	 * A component helper for generating a item title.
52
-	 *
53
-	 * @param $text string The text to be used as the value.
54
-	 *
55
-	 * @return string The sanitized item.
56
-	 */
57
-	public static function title( $text ) {
58
-		$output = '';
59
-
60
-		if ( $text ) {
61
-			$output = ' title="' . esc_attr( $text ) . '" ';
62
-		}
63
-
64
-		return $output;
65
-	}
66
-
67
-	/**
68
-	 * A component helper for generating a item value.
69
-	 *
70
-	 * @param $text string The text to be used as the value.
71
-	 *
72
-	 * @return string The sanitized item.
73
-	 */
74
-	public static function value( $text ) {
75
-		$output = '';
76
-
77
-		if ( $text !== null && $text !== false ) {
78
-			$output = ' value="' . esc_attr( wp_unslash( $text ) ) . '" ';
79
-		}
80
-
81
-		return $output;
82
-	}
83
-
84
-	/**
85
-	 * A component helper for generating a item class attribute.
86
-	 *
87
-	 * @param $text string The text to be used as the value.
88
-	 *
89
-	 * @return string The sanitized item.
90
-	 */
91
-	public static function class_attr( $text ) {
92
-		$output = '';
93
-
94
-		if ( $text ) {
95
-			$classes = self::esc_classes( $text );
96
-			if ( ! empty( $classes ) ) {
97
-				$output = ' class="' . $classes . '" ';
98
-			}
99
-		}
100
-
101
-		return $output;
102
-	}
103
-
104
-	/**
105
-	 * Escape a string of classes.
106
-	 *
107
-	 * @param $text
108
-	 *
109
-	 * @return string
110
-	 */
111
-	public static function esc_classes( $text ) {
112
-		$output = '';
113
-
114
-		if ( $text ) {
115
-			$classes = explode( " ", $text );
116
-			$classes = array_map( "trim", $classes );
117
-			$classes = array_map( "sanitize_html_class", $classes );
118
-			if ( ! empty( $classes ) ) {
119
-				$output = implode( " ", $classes );
120
-			}
121
-		}
122
-
123
-		return $output;
124
-
125
-	}
126
-
127
-	/**
128
-	 * @param $args
129
-	 *
130
-	 * @return string
131
-	 */
132
-	public static function data_attributes( $args ) {
133
-		$output = '';
134
-
135
-		if ( ! empty( $args ) ) {
136
-
137
-			foreach ( $args as $key => $val ) {
138
-				if ( substr( $key, 0, 5 ) === "data-" ) {
139
-					$output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
140
-				}
141
-			}
142
-		}
143
-
144
-		return $output;
145
-	}
146
-
147
-	/**
148
-	 * @param $args
149
-	 *
150
-	 * @return string
151
-	 */
152
-	public static function aria_attributes( $args ) {
153
-		$output = '';
154
-
155
-		if ( ! empty( $args ) ) {
156
-
157
-			foreach ( $args as $key => $val ) {
158
-				if ( substr( $key, 0, 5 ) === "aria-" ) {
159
-					$output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
160
-				}
161
-			}
162
-		}
163
-
164
-		return $output;
165
-	}
166
-
167
-	/**
168
-	 * Build a font awesome icon from a class.
169
-	 *
170
-	 * @param $class
171
-	 * @param bool $space_after
172
-	 * @param array $extra_attributes An array of extra attributes.
173
-	 *
174
-	 * @return string
175
-	 */
176
-	public static function icon( $class, $space_after = false, $extra_attributes = array() ) {
177
-		$output = '';
178
-
179
-		if ( $class ) {
180
-			$classes = self::esc_classes( $class );
181
-			if ( ! empty( $classes ) ) {
182
-				$output = '<i class="' . $classes . '" ';
183
-				// extra attributes
184
-				if ( ! empty( $extra_attributes ) ) {
185
-					$output .= AUI_Component_Helper::extra_attributes( $extra_attributes );
186
-				}
187
-				$output .= '></i>';
188
-				if ( $space_after ) {
189
-					$output .= " ";
190
-				}
191
-			}
192
-		}
193
-
194
-		return $output;
195
-	}
196
-
197
-	/**
198
-	 * @param $args
199
-	 *
200
-	 * @return string
201
-	 */
202
-	public static function extra_attributes( $args ) {
203
-		$output = '';
204
-
205
-		if ( ! empty( $args ) ) {
206
-
207
-			if ( is_array( $args ) ) {
208
-				foreach ( $args as $key => $val ) {
209
-					$output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
210
-				}
211
-			} else {
212
-				$output .= ' ' . $args . ' ';
213
-			}
214
-
215
-		}
216
-
217
-		return $output;
218
-	}
219
-
220
-	/**
221
-	 * @param $args
222
-	 *
223
-	 * @return string
224
-	 */
225
-	public static function help_text( $text ) {
226
-		$output = '';
227
-
228
-		if ( $text ) {
229
-			$output .= '<small class="form-text text-muted">' . wp_kses_post( $text ) . '</small>';
230
-		}
231
-
232
-
233
-		return $output;
234
-	}
235
-
236
-	/**
237
-	 * Replace element require context with JS.
238
-	 *
239
-	 * @param $input
240
-	 *
241
-	 * @return string|void
242
-	 */
243
-	public static function element_require( $input ) {
244
-
245
-		$input = str_replace( "'", '"', $input );// we only want double quotes
246
-
247
-		$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
248
-			"jQuery(form).find('[data-argument=\"",
249
-			"\"]').find('input,select,textarea').val()",
250
-			"\"]').find('input:checked').val()",
251
-		), $input ) );
252
-
253
-		if ( $output ) {
254
-			$output = ' data-element-require="' . $output . '" ';
255
-		}
256
-
257
-		return $output;
258
-	}
259
-
260
-	/**
261
-	 * Navigates through an array, object, or scalar, and removes slashes from the values.
262
-	 *
263
-	 * @since 0.1.41
264
-	 *
265
-	 * @param mixed $value The value to be stripped.
266
-	 * @param array $input Input Field.
267
-	 *
268
-	 * @return mixed Stripped value.
269
-	 */
270
-	public static function sanitize_html_field( $value, $input = array() ) {
271
-		$original = $value;
272
-
273
-		if ( is_array( $value ) ) {
274
-			foreach ( $value as $index => $item ) {
275
-				$value[ $index ] = self::_sanitize_html_field( $value, $input );
276
-			}
277
-		} elseif ( is_object( $value ) ) {
278
-			$object_vars = get_object_vars( $value );
279
-
280
-			foreach ( $object_vars as $property_name => $property_value ) {
281
-				$value->$property_name = self::_sanitize_html_field( $property_value, $input );
282
-			}
283
-		} else {
284
-			$value = self::_sanitize_html_field( $value, $input );
285
-		}
286
-
287
-		/**
288
-		 * Filters content and keeps only allowable HTML elements.
289
-		 *
290
-		 * @since 0.1.41
291
-		 *
292
-		 * @param string|array $value Content to filter through kses.
293
-		 * @param string|array $value Original content without filter.
294
-		 * @param array $input Input Field.
295
-		 */
296
-		return apply_filters( 'ayecode_ui_sanitize_html_field', $value, $original, $input );
297
-	}
298
-
299
-	/**
300
-	 * Filters content and keeps only allowable HTML elements.
301
-	 *
302
-	 * This function makes sure that only the allowed HTML element names, attribute
303
-	 * names and attribute values plus only sane HTML entities will occur in
304
-	 * $string. You have to remove any slashes from PHP's magic quotes before you
305
-	 * call this function.
306
-	 *
307
-	 * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news',
308
-	 * 'irc', 'gopher', 'nntp', 'feed', 'telnet, 'mms', 'rtsp' and 'svn'. This
309
-	 * covers all common link protocols, except for 'javascript' which should not
310
-	 * be allowed for untrusted users.
311
-	 *
312
-	 * @since 0.1.41
313
-	 *
314
-	 * @param string|array $value Content to filter through kses.
315
-	 * @param array $input Input Field.
316
-	 *
317
-	 * @return string Filtered content with only allowed HTML elements.
318
-	 */
319
-	public static function _sanitize_html_field( $value, $input = array() ) {
320
-		if ( $value === '' ) {
321
-			return $value;
322
-		}
323
-
324
-		$allowed_html = self::kses_allowed_html( 'post', $input );
325
-
326
-		if ( ! is_array( $allowed_html ) ) {
327
-			$allowed_html = wp_kses_allowed_html( 'post' );
328
-		}
329
-
330
-		$filtered = trim( wp_unslash( $value ) );
331
-		$filtered = wp_kses( $filtered, $allowed_html );
332
-		$filtered = balanceTags( $filtered ); // Balances tags
333
-
334
-		return $filtered;
335
-	}
336
-
337
-	/**
338
-	 * Returns an array of allowed HTML tags and attributes for a given context.
339
-	 *
340
-	 * @since 0.1.41
341
-	 *
342
-	 * @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
343
-	 *                              'strip', 'data', 'entities', or the name of a field filter such as
344
-	 *                              'pre_user_description'.
345
-	 * @param array $input Input.
346
-	 *
347
-	 * @return array Array of allowed HTML tags and their allowed attributes.
348
-	 */
349
-	public static function kses_allowed_html( $context = 'post', $input = array() ) {
350
-		$allowed_html = wp_kses_allowed_html( $context );
351
-
352
-		if ( is_array( $allowed_html ) ) {
353
-			// <iframe>
354
-			if ( ! isset( $allowed_html['iframe'] ) && $context == 'post' ) {
355
-				$allowed_html['iframe'] = array(
356
-					'class'           => true,
357
-					'id'              => true,
358
-					'src'             => true,
359
-					'width'           => true,
360
-					'height'          => true,
361
-					'frameborder'     => true,
362
-					'marginwidth'     => true,
363
-					'marginheight'    => true,
364
-					'scrolling'       => true,
365
-					'style'           => true,
366
-					'title'           => true,
367
-					'allow'           => true,
368
-					'allowfullscreen' => true,
369
-					'data-*'          => true,
370
-				);
371
-			}
372
-		}
373
-
374
-		/**
375
-		 * Filters the allowed html tags.
376
-		 *
377
-		 * @since 0.1.41
378
-		 *
379
-		 * @param array[]|string $allowed_html Allowed html tags.
380
-		 * @param @param string|array $context The context for which to retrieve tags.
381
-		 * @param array $input Input field.
382
-		 */
383
-		return apply_filters( 'ayecode_ui_kses_allowed_html', $allowed_html, $context, $input );
384
-	}
385
-
386
-	public static function get_column_class( $label_number = 2, $type = 'label' ) {
387
-
388
-		$class = '';
389
-
390
-		// set default if empty
391
-		if( $label_number === '' ){
392
-			$label_number = 2;
393
-		}
394
-
395
-		if ( $label_number && $label_number < 12 && $label_number > 0 ) {
396
-			if ( $type == 'label' ) {
397
-				$class = 'col-sm-' . absint( $label_number );
398
-			} elseif ( $type == 'input' ) {
399
-				$class = 'col-sm-' . ( 12 - absint( $label_number ) );
400
-			}
401
-		}
402
-
403
-		return $class;
404
-	}
14
+    /**
15
+     * A component helper for generating a input name.
16
+     *
17
+     * @param $text
18
+     * @param $multiple bool If the name is set to be multiple but no brackets found then we add some.
19
+     *
20
+     * @return string
21
+     */
22
+    public static function name( $text, $multiple = false ) {
23
+        $output = '';
24
+
25
+        if ( $text ) {
26
+            $is_multiple = strpos( $text, '[' ) === false && $multiple ? '[]' : '';
27
+            $output      = ' name="' . esc_attr( $text ) . $is_multiple . '" ';
28
+        }
29
+
30
+        return $output;
31
+    }
32
+
33
+    /**
34
+     * A component helper for generating a item id.
35
+     *
36
+     * @param $text string The text to be used as the value.
37
+     *
38
+     * @return string The sanitized item.
39
+     */
40
+    public static function id( $text ) {
41
+        $output = '';
42
+
43
+        if ( $text ) {
44
+            $output = ' id="' . sanitize_html_class( $text ) . '" ';
45
+        }
46
+
47
+        return $output;
48
+    }
49
+
50
+    /**
51
+     * A component helper for generating a item title.
52
+     *
53
+     * @param $text string The text to be used as the value.
54
+     *
55
+     * @return string The sanitized item.
56
+     */
57
+    public static function title( $text ) {
58
+        $output = '';
59
+
60
+        if ( $text ) {
61
+            $output = ' title="' . esc_attr( $text ) . '" ';
62
+        }
63
+
64
+        return $output;
65
+    }
66
+
67
+    /**
68
+     * A component helper for generating a item value.
69
+     *
70
+     * @param $text string The text to be used as the value.
71
+     *
72
+     * @return string The sanitized item.
73
+     */
74
+    public static function value( $text ) {
75
+        $output = '';
76
+
77
+        if ( $text !== null && $text !== false ) {
78
+            $output = ' value="' . esc_attr( wp_unslash( $text ) ) . '" ';
79
+        }
80
+
81
+        return $output;
82
+    }
83
+
84
+    /**
85
+     * A component helper for generating a item class attribute.
86
+     *
87
+     * @param $text string The text to be used as the value.
88
+     *
89
+     * @return string The sanitized item.
90
+     */
91
+    public static function class_attr( $text ) {
92
+        $output = '';
93
+
94
+        if ( $text ) {
95
+            $classes = self::esc_classes( $text );
96
+            if ( ! empty( $classes ) ) {
97
+                $output = ' class="' . $classes . '" ';
98
+            }
99
+        }
100
+
101
+        return $output;
102
+    }
103
+
104
+    /**
105
+     * Escape a string of classes.
106
+     *
107
+     * @param $text
108
+     *
109
+     * @return string
110
+     */
111
+    public static function esc_classes( $text ) {
112
+        $output = '';
113
+
114
+        if ( $text ) {
115
+            $classes = explode( " ", $text );
116
+            $classes = array_map( "trim", $classes );
117
+            $classes = array_map( "sanitize_html_class", $classes );
118
+            if ( ! empty( $classes ) ) {
119
+                $output = implode( " ", $classes );
120
+            }
121
+        }
122
+
123
+        return $output;
124
+
125
+    }
126
+
127
+    /**
128
+     * @param $args
129
+     *
130
+     * @return string
131
+     */
132
+    public static function data_attributes( $args ) {
133
+        $output = '';
134
+
135
+        if ( ! empty( $args ) ) {
136
+
137
+            foreach ( $args as $key => $val ) {
138
+                if ( substr( $key, 0, 5 ) === "data-" ) {
139
+                    $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
140
+                }
141
+            }
142
+        }
143
+
144
+        return $output;
145
+    }
146
+
147
+    /**
148
+     * @param $args
149
+     *
150
+     * @return string
151
+     */
152
+    public static function aria_attributes( $args ) {
153
+        $output = '';
154
+
155
+        if ( ! empty( $args ) ) {
156
+
157
+            foreach ( $args as $key => $val ) {
158
+                if ( substr( $key, 0, 5 ) === "aria-" ) {
159
+                    $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
160
+                }
161
+            }
162
+        }
163
+
164
+        return $output;
165
+    }
166
+
167
+    /**
168
+     * Build a font awesome icon from a class.
169
+     *
170
+     * @param $class
171
+     * @param bool $space_after
172
+     * @param array $extra_attributes An array of extra attributes.
173
+     *
174
+     * @return string
175
+     */
176
+    public static function icon( $class, $space_after = false, $extra_attributes = array() ) {
177
+        $output = '';
178
+
179
+        if ( $class ) {
180
+            $classes = self::esc_classes( $class );
181
+            if ( ! empty( $classes ) ) {
182
+                $output = '<i class="' . $classes . '" ';
183
+                // extra attributes
184
+                if ( ! empty( $extra_attributes ) ) {
185
+                    $output .= AUI_Component_Helper::extra_attributes( $extra_attributes );
186
+                }
187
+                $output .= '></i>';
188
+                if ( $space_after ) {
189
+                    $output .= " ";
190
+                }
191
+            }
192
+        }
193
+
194
+        return $output;
195
+    }
196
+
197
+    /**
198
+     * @param $args
199
+     *
200
+     * @return string
201
+     */
202
+    public static function extra_attributes( $args ) {
203
+        $output = '';
204
+
205
+        if ( ! empty( $args ) ) {
206
+
207
+            if ( is_array( $args ) ) {
208
+                foreach ( $args as $key => $val ) {
209
+                    $output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
210
+                }
211
+            } else {
212
+                $output .= ' ' . $args . ' ';
213
+            }
214
+
215
+        }
216
+
217
+        return $output;
218
+    }
219
+
220
+    /**
221
+     * @param $args
222
+     *
223
+     * @return string
224
+     */
225
+    public static function help_text( $text ) {
226
+        $output = '';
227
+
228
+        if ( $text ) {
229
+            $output .= '<small class="form-text text-muted">' . wp_kses_post( $text ) . '</small>';
230
+        }
231
+
232
+
233
+        return $output;
234
+    }
235
+
236
+    /**
237
+     * Replace element require context with JS.
238
+     *
239
+     * @param $input
240
+     *
241
+     * @return string|void
242
+     */
243
+    public static function element_require( $input ) {
244
+
245
+        $input = str_replace( "'", '"', $input );// we only want double quotes
246
+
247
+        $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
248
+            "jQuery(form).find('[data-argument=\"",
249
+            "\"]').find('input,select,textarea').val()",
250
+            "\"]').find('input:checked').val()",
251
+        ), $input ) );
252
+
253
+        if ( $output ) {
254
+            $output = ' data-element-require="' . $output . '" ';
255
+        }
256
+
257
+        return $output;
258
+    }
259
+
260
+    /**
261
+     * Navigates through an array, object, or scalar, and removes slashes from the values.
262
+     *
263
+     * @since 0.1.41
264
+     *
265
+     * @param mixed $value The value to be stripped.
266
+     * @param array $input Input Field.
267
+     *
268
+     * @return mixed Stripped value.
269
+     */
270
+    public static function sanitize_html_field( $value, $input = array() ) {
271
+        $original = $value;
272
+
273
+        if ( is_array( $value ) ) {
274
+            foreach ( $value as $index => $item ) {
275
+                $value[ $index ] = self::_sanitize_html_field( $value, $input );
276
+            }
277
+        } elseif ( is_object( $value ) ) {
278
+            $object_vars = get_object_vars( $value );
279
+
280
+            foreach ( $object_vars as $property_name => $property_value ) {
281
+                $value->$property_name = self::_sanitize_html_field( $property_value, $input );
282
+            }
283
+        } else {
284
+            $value = self::_sanitize_html_field( $value, $input );
285
+        }
286
+
287
+        /**
288
+         * Filters content and keeps only allowable HTML elements.
289
+         *
290
+         * @since 0.1.41
291
+         *
292
+         * @param string|array $value Content to filter through kses.
293
+         * @param string|array $value Original content without filter.
294
+         * @param array $input Input Field.
295
+         */
296
+        return apply_filters( 'ayecode_ui_sanitize_html_field', $value, $original, $input );
297
+    }
298
+
299
+    /**
300
+     * Filters content and keeps only allowable HTML elements.
301
+     *
302
+     * This function makes sure that only the allowed HTML element names, attribute
303
+     * names and attribute values plus only sane HTML entities will occur in
304
+     * $string. You have to remove any slashes from PHP's magic quotes before you
305
+     * call this function.
306
+     *
307
+     * The default allowed protocols are 'http', 'https', 'ftp', 'mailto', 'news',
308
+     * 'irc', 'gopher', 'nntp', 'feed', 'telnet, 'mms', 'rtsp' and 'svn'. This
309
+     * covers all common link protocols, except for 'javascript' which should not
310
+     * be allowed for untrusted users.
311
+     *
312
+     * @since 0.1.41
313
+     *
314
+     * @param string|array $value Content to filter through kses.
315
+     * @param array $input Input Field.
316
+     *
317
+     * @return string Filtered content with only allowed HTML elements.
318
+     */
319
+    public static function _sanitize_html_field( $value, $input = array() ) {
320
+        if ( $value === '' ) {
321
+            return $value;
322
+        }
323
+
324
+        $allowed_html = self::kses_allowed_html( 'post', $input );
325
+
326
+        if ( ! is_array( $allowed_html ) ) {
327
+            $allowed_html = wp_kses_allowed_html( 'post' );
328
+        }
329
+
330
+        $filtered = trim( wp_unslash( $value ) );
331
+        $filtered = wp_kses( $filtered, $allowed_html );
332
+        $filtered = balanceTags( $filtered ); // Balances tags
333
+
334
+        return $filtered;
335
+    }
336
+
337
+    /**
338
+     * Returns an array of allowed HTML tags and attributes for a given context.
339
+     *
340
+     * @since 0.1.41
341
+     *
342
+     * @param string|array $context The context for which to retrieve tags. Allowed values are 'post',
343
+     *                              'strip', 'data', 'entities', or the name of a field filter such as
344
+     *                              'pre_user_description'.
345
+     * @param array $input Input.
346
+     *
347
+     * @return array Array of allowed HTML tags and their allowed attributes.
348
+     */
349
+    public static function kses_allowed_html( $context = 'post', $input = array() ) {
350
+        $allowed_html = wp_kses_allowed_html( $context );
351
+
352
+        if ( is_array( $allowed_html ) ) {
353
+            // <iframe>
354
+            if ( ! isset( $allowed_html['iframe'] ) && $context == 'post' ) {
355
+                $allowed_html['iframe'] = array(
356
+                    'class'           => true,
357
+                    'id'              => true,
358
+                    'src'             => true,
359
+                    'width'           => true,
360
+                    'height'          => true,
361
+                    'frameborder'     => true,
362
+                    'marginwidth'     => true,
363
+                    'marginheight'    => true,
364
+                    'scrolling'       => true,
365
+                    'style'           => true,
366
+                    'title'           => true,
367
+                    'allow'           => true,
368
+                    'allowfullscreen' => true,
369
+                    'data-*'          => true,
370
+                );
371
+            }
372
+        }
373
+
374
+        /**
375
+         * Filters the allowed html tags.
376
+         *
377
+         * @since 0.1.41
378
+         *
379
+         * @param array[]|string $allowed_html Allowed html tags.
380
+         * @param @param string|array $context The context for which to retrieve tags.
381
+         * @param array $input Input field.
382
+         */
383
+        return apply_filters( 'ayecode_ui_kses_allowed_html', $allowed_html, $context, $input );
384
+    }
385
+
386
+    public static function get_column_class( $label_number = 2, $type = 'label' ) {
387
+
388
+        $class = '';
389
+
390
+        // set default if empty
391
+        if( $label_number === '' ){
392
+            $label_number = 2;
393
+        }
394
+
395
+        if ( $label_number && $label_number < 12 && $label_number > 0 ) {
396
+            if ( $type == 'label' ) {
397
+                $class = 'col-sm-' . absint( $label_number );
398
+            } elseif ( $type == 'input' ) {
399
+                $class = 'col-sm-' . ( 12 - absint( $label_number ) );
400
+            }
401
+        }
402
+
403
+        return $class;
404
+    }
405 405
 }
406 406
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @return string
21 21
 	 */
22
-	public static function name( $text, $multiple = false ) {
22
+	public static function name($text, $multiple = false) {
23 23
 		$output = '';
24 24
 
25
-		if ( $text ) {
26
-			$is_multiple = strpos( $text, '[' ) === false && $multiple ? '[]' : '';
27
-			$output      = ' name="' . esc_attr( $text ) . $is_multiple . '" ';
25
+		if ($text) {
26
+			$is_multiple = strpos($text, '[') === false && $multiple ? '[]' : '';
27
+			$output      = ' name="' . esc_attr($text) . $is_multiple . '" ';
28 28
 		}
29 29
 
30 30
 		return $output;
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @return string The sanitized item.
39 39
 	 */
40
-	public static function id( $text ) {
40
+	public static function id($text) {
41 41
 		$output = '';
42 42
 
43
-		if ( $text ) {
44
-			$output = ' id="' . sanitize_html_class( $text ) . '" ';
43
+		if ($text) {
44
+			$output = ' id="' . sanitize_html_class($text) . '" ';
45 45
 		}
46 46
 
47 47
 		return $output;
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return string The sanitized item.
56 56
 	 */
57
-	public static function title( $text ) {
57
+	public static function title($text) {
58 58
 		$output = '';
59 59
 
60
-		if ( $text ) {
61
-			$output = ' title="' . esc_attr( $text ) . '" ';
60
+		if ($text) {
61
+			$output = ' title="' . esc_attr($text) . '" ';
62 62
 		}
63 63
 
64 64
 		return $output;
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return string The sanitized item.
73 73
 	 */
74
-	public static function value( $text ) {
74
+	public static function value($text) {
75 75
 		$output = '';
76 76
 
77
-		if ( $text !== null && $text !== false ) {
78
-			$output = ' value="' . esc_attr( wp_unslash( $text ) ) . '" ';
77
+		if ($text !== null && $text !== false) {
78
+			$output = ' value="' . esc_attr(wp_unslash($text)) . '" ';
79 79
 		}
80 80
 
81 81
 		return $output;
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return string The sanitized item.
90 90
 	 */
91
-	public static function class_attr( $text ) {
91
+	public static function class_attr($text) {
92 92
 		$output = '';
93 93
 
94
-		if ( $text ) {
95
-			$classes = self::esc_classes( $text );
96
-			if ( ! empty( $classes ) ) {
94
+		if ($text) {
95
+			$classes = self::esc_classes($text);
96
+			if (!empty($classes)) {
97 97
 				$output = ' class="' . $classes . '" ';
98 98
 			}
99 99
 		}
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return string
110 110
 	 */
111
-	public static function esc_classes( $text ) {
111
+	public static function esc_classes($text) {
112 112
 		$output = '';
113 113
 
114
-		if ( $text ) {
115
-			$classes = explode( " ", $text );
116
-			$classes = array_map( "trim", $classes );
117
-			$classes = array_map( "sanitize_html_class", $classes );
118
-			if ( ! empty( $classes ) ) {
119
-				$output = implode( " ", $classes );
114
+		if ($text) {
115
+			$classes = explode(" ", $text);
116
+			$classes = array_map("trim", $classes);
117
+			$classes = array_map("sanitize_html_class", $classes);
118
+			if (!empty($classes)) {
119
+				$output = implode(" ", $classes);
120 120
 			}
121 121
 		}
122 122
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return string
131 131
 	 */
132
-	public static function data_attributes( $args ) {
132
+	public static function data_attributes($args) {
133 133
 		$output = '';
134 134
 
135
-		if ( ! empty( $args ) ) {
135
+		if (!empty($args)) {
136 136
 
137
-			foreach ( $args as $key => $val ) {
138
-				if ( substr( $key, 0, 5 ) === "data-" ) {
139
-					$output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
137
+			foreach ($args as $key => $val) {
138
+				if (substr($key, 0, 5) === "data-") {
139
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
140 140
 				}
141 141
 			}
142 142
 		}
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @return string
151 151
 	 */
152
-	public static function aria_attributes( $args ) {
152
+	public static function aria_attributes($args) {
153 153
 		$output = '';
154 154
 
155
-		if ( ! empty( $args ) ) {
155
+		if (!empty($args)) {
156 156
 
157
-			foreach ( $args as $key => $val ) {
158
-				if ( substr( $key, 0, 5 ) === "aria-" ) {
159
-					$output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
157
+			foreach ($args as $key => $val) {
158
+				if (substr($key, 0, 5) === "aria-") {
159
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
160 160
 				}
161 161
 			}
162 162
 		}
@@ -173,19 +173,19 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @return string
175 175
 	 */
176
-	public static function icon( $class, $space_after = false, $extra_attributes = array() ) {
176
+	public static function icon($class, $space_after = false, $extra_attributes = array()) {
177 177
 		$output = '';
178 178
 
179
-		if ( $class ) {
180
-			$classes = self::esc_classes( $class );
181
-			if ( ! empty( $classes ) ) {
179
+		if ($class) {
180
+			$classes = self::esc_classes($class);
181
+			if (!empty($classes)) {
182 182
 				$output = '<i class="' . $classes . '" ';
183 183
 				// extra attributes
184
-				if ( ! empty( $extra_attributes ) ) {
185
-					$output .= AUI_Component_Helper::extra_attributes( $extra_attributes );
184
+				if (!empty($extra_attributes)) {
185
+					$output .= AUI_Component_Helper::extra_attributes($extra_attributes);
186 186
 				}
187 187
 				$output .= '></i>';
188
-				if ( $space_after ) {
188
+				if ($space_after) {
189 189
 					$output .= " ";
190 190
 				}
191 191
 			}
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return string
201 201
 	 */
202
-	public static function extra_attributes( $args ) {
202
+	public static function extra_attributes($args) {
203 203
 		$output = '';
204 204
 
205
-		if ( ! empty( $args ) ) {
205
+		if (!empty($args)) {
206 206
 
207
-			if ( is_array( $args ) ) {
208
-				foreach ( $args as $key => $val ) {
209
-					$output .= ' ' . sanitize_html_class( $key ) . '="' . esc_attr( $val ) . '" ';
207
+			if (is_array($args)) {
208
+				foreach ($args as $key => $val) {
209
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
210 210
 				}
211 211
 			} else {
212 212
 				$output .= ' ' . $args . ' ';
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @return string
224 224
 	 */
225
-	public static function help_text( $text ) {
225
+	public static function help_text($text) {
226 226
 		$output = '';
227 227
 
228
-		if ( $text ) {
229
-			$output .= '<small class="form-text text-muted">' . wp_kses_post( $text ) . '</small>';
228
+		if ($text) {
229
+			$output .= '<small class="form-text text-muted">' . wp_kses_post($text) . '</small>';
230 230
 		}
231 231
 
232 232
 
@@ -240,17 +240,17 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @return string|void
242 242
 	 */
243
-	public static function element_require( $input ) {
243
+	public static function element_require($input) {
244 244
 
245
-		$input = str_replace( "'", '"', $input );// we only want double quotes
245
+		$input = str_replace("'", '"', $input); // we only want double quotes
246 246
 
247
-		$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
247
+		$output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array(
248 248
 			"jQuery(form).find('[data-argument=\"",
249 249
 			"\"]').find('input,select,textarea').val()",
250 250
 			"\"]').find('input:checked').val()",
251
-		), $input ) );
251
+		), $input));
252 252
 
253
-		if ( $output ) {
253
+		if ($output) {
254 254
 			$output = ' data-element-require="' . $output . '" ';
255 255
 		}
256 256
 
@@ -267,21 +267,21 @@  discard block
 block discarded – undo
267 267
 	 *
268 268
 	 * @return mixed Stripped value.
269 269
 	 */
270
-	public static function sanitize_html_field( $value, $input = array() ) {
270
+	public static function sanitize_html_field($value, $input = array()) {
271 271
 		$original = $value;
272 272
 
273
-		if ( is_array( $value ) ) {
274
-			foreach ( $value as $index => $item ) {
275
-				$value[ $index ] = self::_sanitize_html_field( $value, $input );
273
+		if (is_array($value)) {
274
+			foreach ($value as $index => $item) {
275
+				$value[$index] = self::_sanitize_html_field($value, $input);
276 276
 			}
277
-		} elseif ( is_object( $value ) ) {
278
-			$object_vars = get_object_vars( $value );
277
+		} elseif (is_object($value)) {
278
+			$object_vars = get_object_vars($value);
279 279
 
280
-			foreach ( $object_vars as $property_name => $property_value ) {
281
-				$value->$property_name = self::_sanitize_html_field( $property_value, $input );
280
+			foreach ($object_vars as $property_name => $property_value) {
281
+				$value->$property_name = self::_sanitize_html_field($property_value, $input);
282 282
 			}
283 283
 		} else {
284
-			$value = self::_sanitize_html_field( $value, $input );
284
+			$value = self::_sanitize_html_field($value, $input);
285 285
 		}
286 286
 
287 287
 		/**
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 		 * @param string|array $value Original content without filter.
294 294
 		 * @param array $input Input Field.
295 295
 		 */
296
-		return apply_filters( 'ayecode_ui_sanitize_html_field', $value, $original, $input );
296
+		return apply_filters('ayecode_ui_sanitize_html_field', $value, $original, $input);
297 297
 	}
298 298
 
299 299
 	/**
@@ -316,20 +316,20 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @return string Filtered content with only allowed HTML elements.
318 318
 	 */
319
-	public static function _sanitize_html_field( $value, $input = array() ) {
320
-		if ( $value === '' ) {
319
+	public static function _sanitize_html_field($value, $input = array()) {
320
+		if ($value === '') {
321 321
 			return $value;
322 322
 		}
323 323
 
324
-		$allowed_html = self::kses_allowed_html( 'post', $input );
324
+		$allowed_html = self::kses_allowed_html('post', $input);
325 325
 
326
-		if ( ! is_array( $allowed_html ) ) {
327
-			$allowed_html = wp_kses_allowed_html( 'post' );
326
+		if (!is_array($allowed_html)) {
327
+			$allowed_html = wp_kses_allowed_html('post');
328 328
 		}
329 329
 
330
-		$filtered = trim( wp_unslash( $value ) );
331
-		$filtered = wp_kses( $filtered, $allowed_html );
332
-		$filtered = balanceTags( $filtered ); // Balances tags
330
+		$filtered = trim(wp_unslash($value));
331
+		$filtered = wp_kses($filtered, $allowed_html);
332
+		$filtered = balanceTags($filtered); // Balances tags
333 333
 
334 334
 		return $filtered;
335 335
 	}
@@ -346,12 +346,12 @@  discard block
 block discarded – undo
346 346
 	 *
347 347
 	 * @return array Array of allowed HTML tags and their allowed attributes.
348 348
 	 */
349
-	public static function kses_allowed_html( $context = 'post', $input = array() ) {
350
-		$allowed_html = wp_kses_allowed_html( $context );
349
+	public static function kses_allowed_html($context = 'post', $input = array()) {
350
+		$allowed_html = wp_kses_allowed_html($context);
351 351
 
352
-		if ( is_array( $allowed_html ) ) {
352
+		if (is_array($allowed_html)) {
353 353
 			// <iframe>
354
-			if ( ! isset( $allowed_html['iframe'] ) && $context == 'post' ) {
354
+			if (!isset($allowed_html['iframe']) && $context == 'post') {
355 355
 				$allowed_html['iframe'] = array(
356 356
 					'class'           => true,
357 357
 					'id'              => true,
@@ -380,23 +380,23 @@  discard block
 block discarded – undo
380 380
 		 * @param @param string|array $context The context for which to retrieve tags.
381 381
 		 * @param array $input Input field.
382 382
 		 */
383
-		return apply_filters( 'ayecode_ui_kses_allowed_html', $allowed_html, $context, $input );
383
+		return apply_filters('ayecode_ui_kses_allowed_html', $allowed_html, $context, $input);
384 384
 	}
385 385
 
386
-	public static function get_column_class( $label_number = 2, $type = 'label' ) {
386
+	public static function get_column_class($label_number = 2, $type = 'label') {
387 387
 
388 388
 		$class = '';
389 389
 
390 390
 		// set default if empty
391
-		if( $label_number === '' ){
391
+		if ($label_number === '') {
392 392
 			$label_number = 2;
393 393
 		}
394 394
 
395
-		if ( $label_number && $label_number < 12 && $label_number > 0 ) {
396
-			if ( $type == 'label' ) {
397
-				$class = 'col-sm-' . absint( $label_number );
398
-			} elseif ( $type == 'input' ) {
399
-				$class = 'col-sm-' . ( 12 - absint( $label_number ) );
395
+		if ($label_number && $label_number < 12 && $label_number > 0) {
396
+			if ($type == 'label') {
397
+				$class = 'col-sm-' . absint($label_number);
398
+			} elseif ($type == 'input') {
399
+				$class = 'col-sm-' . (12 - absint($label_number));
400 400
 			}
401 401
 		}
402 402
 
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 3 patches
Indentation   +1155 added lines, -1155 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,1179 +11,1179 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Input {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function input( $args = array() ) {
22
-		$defaults = array(
23
-			'type'                     => 'text',
24
-			'name'                     => '',
25
-			'class'                    => '',
26
-			'wrap_class'               => '',
27
-			'id'                       => '',
28
-			'placeholder'              => '',
29
-			'title'                    => '',
30
-			'value'                    => '',
31
-			'required'                 => false,
32
-			'label'                    => '',
33
-			'label_after'              => false,
34
-			'label_class'              => '',
35
-			'label_col'                => '2',
36
-			'label_type'               => '',
37
-			'label_force_left'         => false, // used to force checkbox label left when using horizontal
38
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
39
-			'help_text'                => '',
40
-			'validation_text'          => '',
41
-			'validation_pattern'       => '',
42
-			'no_wrap'                  => false,
43
-			'input_group_right'        => '',
44
-			'input_group_left'         => '',
45
-			'input_group_right_inside' => false,
46
-			// forces the input group inside the input
47
-			'input_group_left_inside'  => false,
48
-			// forces the input group inside the input
49
-			'step'                     => '',
50
-			'switch'                   => false,
51
-			// to show checkbox as a switch
52
-			'checked'                  => false,
53
-			// set a checkbox or radio as selected
54
-			'password_toggle'          => true,
55
-			// toggle view/hide password
56
-			'element_require'          => '',
57
-			// [%element_id%] == "1"
58
-			'extra_attributes'         => array(),
59
-			// an array of extra attributes
60
-			'wrap_attributes'          => array()
61
-		);
62
-
63
-		/**
64
-		 * Parse incoming $args into an array and merge it with $defaults
65
-		 */
66
-		$args   = wp_parse_args( $args, $defaults );
67
-		$output = '';
68
-		if ( ! empty( $args['type'] ) ) {
69
-			// hidden label option needs to be empty
70
-			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
71
-
72
-			$type = sanitize_html_class( $args['type'] );
73
-
74
-			$help_text   = '';
75
-			$label       = '';
76
-			$label_after = $args['label_after'];
77
-			$label_args  = array(
78
-				'title'      => $args['label'],
79
-				'for'        => $args['id'],
80
-				'class'      => $args['label_class'] . " ",
81
-				'label_type' => $args['label_type'],
82
-				'label_col'  => $args['label_col']
83
-			);
84
-
85
-			// floating labels need label after
86
-			if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
87
-				$label_after         = true;
88
-				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
89
-			}
90
-
91
-			// Some special sauce for files
92
-			if ( $type == 'file' ) {
93
-				$label_after = true; // if type file we need the label after
94
-				$args['class'] .= ' custom-file-input ';
95
-			} elseif ( $type == 'checkbox' ) {
96
-				$label_after = true; // if type file we need the label after
97
-				$args['class'] .= ' custom-control-input ';
98
-			} elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
99
-				$type = 'text';
100
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
101
-				$args['class'] .= ' bg-initial ';
102
-
103
-				$args['extra_attributes']['data-aui-init'] = 'flatpickr';
104
-				// enqueue the script
105
-				$aui_settings = AyeCode_UI_Settings::instance();
106
-				$aui_settings->enqueue_flatpickr();
107
-			} elseif ( $type == 'iconpicker' ) {
108
-				$type = 'text';
109
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function input( $args = array() ) {
22
+        $defaults = array(
23
+            'type'                     => 'text',
24
+            'name'                     => '',
25
+            'class'                    => '',
26
+            'wrap_class'               => '',
27
+            'id'                       => '',
28
+            'placeholder'              => '',
29
+            'title'                    => '',
30
+            'value'                    => '',
31
+            'required'                 => false,
32
+            'label'                    => '',
33
+            'label_after'              => false,
34
+            'label_class'              => '',
35
+            'label_col'                => '2',
36
+            'label_type'               => '',
37
+            'label_force_left'         => false, // used to force checkbox label left when using horizontal
38
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
39
+            'help_text'                => '',
40
+            'validation_text'          => '',
41
+            'validation_pattern'       => '',
42
+            'no_wrap'                  => false,
43
+            'input_group_right'        => '',
44
+            'input_group_left'         => '',
45
+            'input_group_right_inside' => false,
46
+            // forces the input group inside the input
47
+            'input_group_left_inside'  => false,
48
+            // forces the input group inside the input
49
+            'step'                     => '',
50
+            'switch'                   => false,
51
+            // to show checkbox as a switch
52
+            'checked'                  => false,
53
+            // set a checkbox or radio as selected
54
+            'password_toggle'          => true,
55
+            // toggle view/hide password
56
+            'element_require'          => '',
57
+            // [%element_id%] == "1"
58
+            'extra_attributes'         => array(),
59
+            // an array of extra attributes
60
+            'wrap_attributes'          => array()
61
+        );
62
+
63
+        /**
64
+         * Parse incoming $args into an array and merge it with $defaults
65
+         */
66
+        $args   = wp_parse_args( $args, $defaults );
67
+        $output = '';
68
+        if ( ! empty( $args['type'] ) ) {
69
+            // hidden label option needs to be empty
70
+            $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
71
+
72
+            $type = sanitize_html_class( $args['type'] );
73
+
74
+            $help_text   = '';
75
+            $label       = '';
76
+            $label_after = $args['label_after'];
77
+            $label_args  = array(
78
+                'title'      => $args['label'],
79
+                'for'        => $args['id'],
80
+                'class'      => $args['label_class'] . " ",
81
+                'label_type' => $args['label_type'],
82
+                'label_col'  => $args['label_col']
83
+            );
84
+
85
+            // floating labels need label after
86
+            if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
87
+                $label_after         = true;
88
+                $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
89
+            }
90
+
91
+            // Some special sauce for files
92
+            if ( $type == 'file' ) {
93
+                $label_after = true; // if type file we need the label after
94
+                $args['class'] .= ' custom-file-input ';
95
+            } elseif ( $type == 'checkbox' ) {
96
+                $label_after = true; // if type file we need the label after
97
+                $args['class'] .= ' custom-control-input ';
98
+            } elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
99
+                $type = 'text';
100
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
101
+                $args['class'] .= ' bg-initial ';
102
+
103
+                $args['extra_attributes']['data-aui-init'] = 'flatpickr';
104
+                // enqueue the script
105
+                $aui_settings = AyeCode_UI_Settings::instance();
106
+                $aui_settings->enqueue_flatpickr();
107
+            } elseif ( $type == 'iconpicker' ) {
108
+                $type = 'text';
109
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
110 110
 //				$args['class'] .= ' bg-initial ';
111 111
 
112
-				$args['extra_attributes']['data-aui-init'] = 'iconpicker';
113
-				$args['extra_attributes']['data-placement'] = 'bottomRight';
112
+                $args['extra_attributes']['data-aui-init'] = 'iconpicker';
113
+                $args['extra_attributes']['data-placement'] = 'bottomRight';
114 114
 
115
-				$args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>';
115
+                $args['input_group_right'] = '<span class="input-group-addon input-group-text c-pointer"></span>';
116 116
 //				$args['input_group_right_inside'] = true;
117
-				// enqueue the script
118
-				$aui_settings = AyeCode_UI_Settings::instance();
119
-				$aui_settings->enqueue_iconpicker();
120
-			}
121
-
122
-			if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) {
123
-				$output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
124
-			}
125
-
126
-
127
-			// open/type
128
-			$output .= '<input type="' . $type . '" ';
129
-
130
-			// name
131
-			if ( ! empty( $args['name'] ) ) {
132
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
133
-			}
134
-
135
-			// id
136
-			if ( ! empty( $args['id'] ) ) {
137
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
138
-			}
139
-
140
-			// placeholder
141
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
142
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
143
-			}
144
-
145
-			// title
146
-			if ( ! empty( $args['title'] ) ) {
147
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
148
-			}
149
-
150
-			// value
151
-			if ( ! empty( $args['value'] ) ) {
152
-				$output .= AUI_Component_Helper::value( $args['value'] );
153
-			}
154
-
155
-			// checked, for radio and checkboxes
156
-			if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
157
-				$output .= ' checked ';
158
-			}
159
-
160
-			// validation text
161
-			if ( ! empty( $args['validation_text'] ) ) {
162
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
163
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
164
-			}
165
-
166
-			// validation_pattern
167
-			if ( ! empty( $args['validation_pattern'] ) ) {
168
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
169
-			}
170
-
171
-			// step (for numbers)
172
-			if ( ! empty( $args['step'] ) ) {
173
-				$output .= ' step="' . $args['step'] . '" ';
174
-			}
175
-
176
-			// required
177
-			if ( ! empty( $args['required'] ) ) {
178
-				$output .= ' required ';
179
-			}
180
-
181
-			// class
182
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
183
-			$output .= ' class="form-control ' . $class . '" ';
184
-
185
-			// data-attributes
186
-			$output .= AUI_Component_Helper::data_attributes( $args );
187
-
188
-			// extra attributes
189
-			if ( ! empty( $args['extra_attributes'] ) ) {
190
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
191
-			}
192
-
193
-			// close
194
-			$output .= ' >';
195
-
196
-			// help text
197
-			if ( ! empty( $args['help_text'] ) ) {
198
-				$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
199
-			}
200
-
201
-			// label
202
-			if ( ! empty( $args['label'] ) ) {
203
-				$label_base_class = '';
204
-				if ( $type == 'file' ) {
205
-					$label_base_class = ' custom-file-label';
206
-				} elseif ( $type == 'checkbox' ) {
207
-					if ( ! empty( $args['label_force_left'] ) ) {
208
-						$label_args['title'] = wp_kses_post( $args['help_text'] );
209
-						$help_text = '';
210
-						//$label_args['class'] .= ' d-inline ';
211
-						$args['wrap_class'] .= ' align-items-center ';
212
-					}else{
213
-
214
-					}
215
-
216
-					$label_base_class = ' custom-control-label';
217
-				}
218
-				$label_args['class'] .= $label_base_class;
219
-				$temp_label_args = $label_args;
220
-				if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
221
-				$label = self::label( $temp_label_args, $type );
222
-			}
223
-
224
-
225
-
226
-
227
-			// set help text in the correct position
228
-			if ( $label_after ) {
229
-				$output .= $label . $help_text;
230
-			}
231
-
232
-			// some input types need a separate wrap
233
-			if ( $type == 'file' ) {
234
-				$output = self::wrap( array(
235
-					'content' => $output,
236
-					'class'   => 'form-group custom-file'
237
-				) );
238
-			} elseif ( $type == 'checkbox' ) {
239
-
240
-				$label_args['title'] = $args['label'];
241
-				$label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
242
-				$label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
243
-				$switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
244
-				$wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox';
245
-				if ( ! empty( $args['label_force_left'] ) ) {
246
-					$wrap_class .= ' d-flex align-content-center';
247
-					$label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) );
248
-				}
249
-				$output     = self::wrap( array(
250
-					'content' => $output,
251
-					'class'   => 'custom-control ' . $wrap_class
252
-				) );
253
-
254
-				if ( $args['label_type'] == 'horizontal' ) {
255
-					$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
256
-					$output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
257
-				}
258
-			} elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
259
-
260
-
261
-				// allow password field to toggle view
262
-				$args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
117
+                // enqueue the script
118
+                $aui_settings = AyeCode_UI_Settings::instance();
119
+                $aui_settings->enqueue_iconpicker();
120
+            }
121
+
122
+            if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) {
123
+                $output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
124
+            }
125
+
126
+
127
+            // open/type
128
+            $output .= '<input type="' . $type . '" ';
129
+
130
+            // name
131
+            if ( ! empty( $args['name'] ) ) {
132
+                $output .= ' name="' . esc_attr( $args['name'] ) . '" ';
133
+            }
134
+
135
+            // id
136
+            if ( ! empty( $args['id'] ) ) {
137
+                $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
138
+            }
139
+
140
+            // placeholder
141
+            if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
142
+                $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
143
+            }
144
+
145
+            // title
146
+            if ( ! empty( $args['title'] ) ) {
147
+                $output .= ' title="' . esc_attr( $args['title'] ) . '" ';
148
+            }
149
+
150
+            // value
151
+            if ( ! empty( $args['value'] ) ) {
152
+                $output .= AUI_Component_Helper::value( $args['value'] );
153
+            }
154
+
155
+            // checked, for radio and checkboxes
156
+            if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
157
+                $output .= ' checked ';
158
+            }
159
+
160
+            // validation text
161
+            if ( ! empty( $args['validation_text'] ) ) {
162
+                $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
163
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
164
+            }
165
+
166
+            // validation_pattern
167
+            if ( ! empty( $args['validation_pattern'] ) ) {
168
+                $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
169
+            }
170
+
171
+            // step (for numbers)
172
+            if ( ! empty( $args['step'] ) ) {
173
+                $output .= ' step="' . $args['step'] . '" ';
174
+            }
175
+
176
+            // required
177
+            if ( ! empty( $args['required'] ) ) {
178
+                $output .= ' required ';
179
+            }
180
+
181
+            // class
182
+            $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
183
+            $output .= ' class="form-control ' . $class . '" ';
184
+
185
+            // data-attributes
186
+            $output .= AUI_Component_Helper::data_attributes( $args );
187
+
188
+            // extra attributes
189
+            if ( ! empty( $args['extra_attributes'] ) ) {
190
+                $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
191
+            }
192
+
193
+            // close
194
+            $output .= ' >';
195
+
196
+            // help text
197
+            if ( ! empty( $args['help_text'] ) ) {
198
+                $help_text = AUI_Component_Helper::help_text( $args['help_text'] );
199
+            }
200
+
201
+            // label
202
+            if ( ! empty( $args['label'] ) ) {
203
+                $label_base_class = '';
204
+                if ( $type == 'file' ) {
205
+                    $label_base_class = ' custom-file-label';
206
+                } elseif ( $type == 'checkbox' ) {
207
+                    if ( ! empty( $args['label_force_left'] ) ) {
208
+                        $label_args['title'] = wp_kses_post( $args['help_text'] );
209
+                        $help_text = '';
210
+                        //$label_args['class'] .= ' d-inline ';
211
+                        $args['wrap_class'] .= ' align-items-center ';
212
+                    }else{
213
+
214
+                    }
215
+
216
+                    $label_base_class = ' custom-control-label';
217
+                }
218
+                $label_args['class'] .= $label_base_class;
219
+                $temp_label_args = $label_args;
220
+                if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
221
+                $label = self::label( $temp_label_args, $type );
222
+            }
223
+
224
+
225
+
226
+
227
+            // set help text in the correct position
228
+            if ( $label_after ) {
229
+                $output .= $label . $help_text;
230
+            }
231
+
232
+            // some input types need a separate wrap
233
+            if ( $type == 'file' ) {
234
+                $output = self::wrap( array(
235
+                    'content' => $output,
236
+                    'class'   => 'form-group custom-file'
237
+                ) );
238
+            } elseif ( $type == 'checkbox' ) {
239
+
240
+                $label_args['title'] = $args['label'];
241
+                $label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
242
+                $label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
243
+                $switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
244
+                $wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox';
245
+                if ( ! empty( $args['label_force_left'] ) ) {
246
+                    $wrap_class .= ' d-flex align-content-center';
247
+                    $label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) );
248
+                }
249
+                $output     = self::wrap( array(
250
+                    'content' => $output,
251
+                    'class'   => 'custom-control ' . $wrap_class
252
+                ) );
253
+
254
+                if ( $args['label_type'] == 'horizontal' ) {
255
+                    $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
256
+                    $output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
257
+                }
258
+            } elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
259
+
260
+
261
+                // allow password field to toggle view
262
+                $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
263 263
 onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\');
264 264
 var $eli = jQuery(this).parent().parent().find(\'input\');
265 265
 if($el.hasClass(\'fa-eye\'))
266 266
 {$eli.attr(\'type\',\'text\');}
267 267
 else{$eli.attr(\'type\',\'password\');}"
268 268
 ><i class="far fa-fw fa-eye-slash"></i></span>';
269
-			}
270
-
271
-			// input group wraps
272
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
273
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
274
-				if ( $args['input_group_left'] ) {
275
-					$output = self::wrap( array(
276
-						'content'                 => $output,
277
-						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
278
-						'input_group_left'        => $args['input_group_left'],
279
-						'input_group_left_inside' => $args['input_group_left_inside']
280
-					) );
281
-				}
282
-				if ( $args['input_group_right'] ) {
283
-					$output = self::wrap( array(
284
-						'content'                  => $output,
285
-						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
286
-						'input_group_right'        => $args['input_group_right'],
287
-						'input_group_right_inside' => $args['input_group_right_inside']
288
-					) );
289
-				}
290
-
291
-			}
292
-
293
-			if ( ! $label_after ) {
294
-				$output .= $help_text;
295
-			}
296
-
297
-
298
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
299
-				$output = self::wrap( array(
300
-					'content' => $output,
301
-					'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
302
-				) );
303
-			}
304
-
305
-			if ( ! $label_after ) {
306
-				$output = $label . $output;
307
-			}
308
-
309
-			// wrap
310
-			if ( ! $args['no_wrap'] ) {
311
-				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
312
-				$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
313
-				$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
-				$output           = self::wrap( array(
315
-					'content'         => $output,
316
-					'class'           => $wrap_class,
317
-					'element_require' => $args['element_require'],
318
-					'argument_id'     => $args['id'],
319
-					'wrap_attributes' => $args['wrap_attributes'],
320
-				) );
321
-			}
322
-		}
323
-
324
-		return $output;
325
-	}
326
-
327
-	public static function label( $args = array(), $type = '' ) {
328
-		//<label for="exampleInputEmail1">Email address</label>
329
-		$defaults = array(
330
-			'title'      => 'div',
331
-			'for'        => '',
332
-			'class'      => '',
333
-			'label_type' => '', // empty = hidden, top, horizontal
334
-			'label_col'  => '',
335
-		);
336
-
337
-		/**
338
-		 * Parse incoming $args into an array and merge it with $defaults
339
-		 */
340
-		$args   = wp_parse_args( $args, $defaults );
341
-		$output = '';
342
-
343
-		if ( $args['title'] ) {
344
-
345
-			// maybe hide labels //@todo set a global option for visibility class
346
-			if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
347
-				$class = $args['class'];
348
-			} else {
349
-				$class = 'sr-only ' . $args['class'];
350
-			}
351
-
352
-			// maybe horizontal
353
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
354
-				$class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label';
355
-			}
356
-
357
-			// open
358
-			$output .= '<label ';
359
-
360
-			// for
361
-			if ( ! empty( $args['for'] ) ) {
362
-				$output .= ' for="' . esc_attr( $args['for'] ) . '" ';
363
-			}
364
-
365
-			// class
366
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
367
-			$output .= ' class="' . $class . '" ';
368
-
369
-			// close
370
-			$output .= '>';
371
-
372
-
373
-			// title, don't escape fully as can contain html
374
-			if ( ! empty( $args['title'] ) ) {
375
-				$output .= wp_kses_post( $args['title'] );
376
-			}
377
-
378
-			// close wrap
379
-			$output .= '</label>';
380
-
381
-
382
-		}
383
-
384
-
385
-		return $output;
386
-	}
387
-
388
-	/**
389
-	 * Wrap some content in a HTML wrapper.
390
-	 *
391
-	 * @param array $args
392
-	 *
393
-	 * @return string
394
-	 */
395
-	public static function wrap( $args = array() ) {
396
-		$defaults = array(
397
-			'type'                     => 'div',
398
-			'class'                    => 'form-group',
399
-			'content'                  => '',
400
-			'input_group_left'         => '',
401
-			'input_group_right'        => '',
402
-			'input_group_left_inside'  => false,
403
-			'input_group_right_inside' => false,
404
-			'element_require'          => '',
405
-			'argument_id'              => '',
406
-			'wrap_attributes'          => array()
407
-		);
408
-
409
-		/**
410
-		 * Parse incoming $args into an array and merge it with $defaults
411
-		 */
412
-		$args   = wp_parse_args( $args, $defaults );
413
-		$output = '';
414
-		if ( $args['type'] ) {
415
-
416
-			// open
417
-			$output .= '<' . sanitize_html_class( $args['type'] );
418
-
419
-			// element require
420
-			if ( ! empty( $args['element_require'] ) ) {
421
-				$output .= AUI_Component_Helper::element_require( $args['element_require'] );
422
-				$args['class'] .= " aui-conditional-field";
423
-			}
424
-
425
-			// argument_id
426
-			if ( ! empty( $args['argument_id'] ) ) {
427
-				$output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
428
-			}
429
-
430
-			// class
431
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
432
-			$output .= ' class="' . $class . '" ';
433
-
434
-			// Attributes
435
-			if ( ! empty( $args['wrap_attributes'] ) ) {
436
-				$output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
437
-			}
438
-
439
-			// close wrap
440
-			$output .= ' >';
441
-
442
-
443
-			// Input group left
444
-			if ( ! empty( $args['input_group_left'] ) ) {
445
-				$position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
446
-				$input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
447
-				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
448
-			}
449
-
450
-			// content
451
-			$output .= $args['content'];
452
-
453
-			// Input group right
454
-			if ( ! empty( $args['input_group_right'] ) ) {
455
-				$position_class    = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
456
-				$input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
457
-				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
458
-			}
459
-
460
-
461
-			// close wrap
462
-			$output .= '</' . sanitize_html_class( $args['type'] ) . '>';
463
-
464
-
465
-		} else {
466
-			$output = $args['content'];
467
-		}
468
-
469
-		return $output;
470
-	}
471
-
472
-	/**
473
-	 * Build the component.
474
-	 *
475
-	 * @param array $args
476
-	 *
477
-	 * @return string The rendered component.
478
-	 */
479
-	public static function textarea( $args = array() ) {
480
-		$defaults = array(
481
-			'name'               => '',
482
-			'class'              => '',
483
-			'wrap_class'         => '',
484
-			'id'                 => '',
485
-			'placeholder'        => '',
486
-			'title'              => '',
487
-			'value'              => '',
488
-			'required'           => false,
489
-			'label'              => '',
490
-			'label_after'        => false,
491
-			'label_class'        => '',
492
-			'label_type'         => '',
493
-			'label_col'          => '',
494
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
495
-			'help_text'          => '',
496
-			'validation_text'    => '',
497
-			'validation_pattern' => '',
498
-			'no_wrap'            => false,
499
-			'rows'               => '',
500
-			'wysiwyg'            => false,
501
-			'allow_tags'         => false,
502
-			// Allow HTML tags
503
-			'element_require'    => '',
504
-			// [%element_id%] == "1"
505
-			'extra_attributes'   => array(),
506
-			// an array of extra attributes
507
-			'wrap_attributes'    => array(),
508
-		);
509
-
510
-		/**
511
-		 * Parse incoming $args into an array and merge it with $defaults
512
-		 */
513
-		$args   = wp_parse_args( $args, $defaults );
514
-		$output = '';
515
-
516
-		// hidden label option needs to be empty
517
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
518
-
519
-		// floating labels don't work with wysiwyg so set it as top
520
-		if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
521
-			$args['label_type'] = 'top';
522
-		}
523
-
524
-		$label_after = $args['label_after'];
525
-
526
-		// floating labels need label after
527
-		if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
528
-			$label_after         = true;
529
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
530
-		}
531
-
532
-		// label
533
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
534
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
535
-			$label_args = array(
536
-				'title'      => $args['label'],
537
-				'for'        => $args['id'],
538
-				'class'      => $args['label_class'] . " ",
539
-				'label_type' => $args['label_type'],
540
-				'label_col'  => $args['label_col']
541
-			);
542
-			$output .= self::label( $label_args );
543
-		}
544
-
545
-		// maybe horizontal label
546
-		if ( $args['label_type'] == 'horizontal' ) {
547
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
548
-			$output .= '<div class="' . $input_col . '">';
549
-		}
550
-
551
-		if ( ! empty( $args['wysiwyg'] ) ) {
552
-			ob_start();
553
-			$content   = $args['value'];
554
-			$editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
555
-			$settings  = array(
556
-				'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
557
-				'quicktags'     => false,
558
-				'media_buttons' => false,
559
-				'editor_class'  => 'form-control',
560
-				'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
561
-				'teeny'         => true,
562
-			);
563
-
564
-			// maybe set settings if array
565
-			if ( is_array( $args['wysiwyg'] ) ) {
566
-				$settings = wp_parse_args( $args['wysiwyg'], $settings );
567
-			}
568
-
569
-			wp_editor( $content, $editor_id, $settings );
570
-			$output .= ob_get_clean();
571
-		} else {
572
-
573
-			// open
574
-			$output .= '<textarea ';
575
-
576
-			// name
577
-			if ( ! empty( $args['name'] ) ) {
578
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
579
-			}
580
-
581
-			// id
582
-			if ( ! empty( $args['id'] ) ) {
583
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
584
-			}
585
-
586
-			// placeholder
587
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
588
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
589
-			}
590
-
591
-			// title
592
-			if ( ! empty( $args['title'] ) ) {
593
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
594
-			}
595
-
596
-			// validation text
597
-			if ( ! empty( $args['validation_text'] ) ) {
598
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
599
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
600
-			}
601
-
602
-			// validation_pattern
603
-			if ( ! empty( $args['validation_pattern'] ) ) {
604
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
605
-			}
606
-
607
-			// required
608
-			if ( ! empty( $args['required'] ) ) {
609
-				$output .= ' required ';
610
-			}
611
-
612
-			// rows
613
-			if ( ! empty( $args['rows'] ) ) {
614
-				$output .= ' rows="' . absint( $args['rows'] ) . '" ';
615
-			}
616
-
617
-
618
-			// class
619
-			$class = ! empty( $args['class'] ) ? $args['class'] : '';
620
-			$output .= ' class="form-control ' . $class . '" ';
621
-
622
-			// extra attributes
623
-			if ( ! empty( $args['extra_attributes'] ) ) {
624
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
625
-			}
626
-
627
-			// close tag
628
-			$output .= ' >';
629
-
630
-			// value
631
-			if ( ! empty( $args['value'] ) ) {
632
-				if ( ! empty( $args['allow_tags'] ) ) {
633
-					$output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
634
-				} else {
635
-					$output .= sanitize_textarea_field( $args['value'] );
636
-				}
637
-			}
638
-
639
-			// closing tag
640
-			$output .= '</textarea>';
641
-
642
-		}
643
-
644
-		if ( ! empty( $args['label'] ) && $label_after ) {
645
-			$label_args = array(
646
-				'title'      => $args['label'],
647
-				'for'        => $args['id'],
648
-				'class'      => $args['label_class'] . " ",
649
-				'label_type' => $args['label_type'],
650
-				'label_col'  => $args['label_col']
651
-			);
652
-			$output .= self::label( $label_args );
653
-		}
654
-
655
-		// help text
656
-		if ( ! empty( $args['help_text'] ) ) {
657
-			$output .= AUI_Component_Helper::help_text( $args['help_text'] );
658
-		}
659
-
660
-		// maybe horizontal label
661
-		if ( $args['label_type'] == 'horizontal' ) {
662
-			$output .= '</div>';
663
-		}
664
-
665
-
666
-		// wrap
667
-		if ( ! $args['no_wrap'] ) {
668
-			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
669
-			$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
670
-			$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
671
-			$output           = self::wrap( array(
672
-				'content'         => $output,
673
-				'class'           => $wrap_class,
674
-				'element_require' => $args['element_require'],
675
-				'argument_id'     => $args['id'],
676
-				'wrap_attributes' => $args['wrap_attributes'],
677
-			) );
678
-		}
679
-
680
-
681
-		return $output;
682
-	}
683
-
684
-	/**
685
-	 * Build the component.
686
-	 *
687
-	 * @param array $args
688
-	 *
689
-	 * @return string The rendered component.
690
-	 */
691
-	public static function select( $args = array() ) {
692
-		$defaults = array(
693
-			'class'            => '',
694
-			'wrap_class'       => '',
695
-			'id'               => '',
696
-			'title'            => '',
697
-			'value'            => '',
698
-			// can be an array or a string
699
-			'required'         => false,
700
-			'label'            => '',
701
-			'label_after'      => false,
702
-			'label_type'       => '',
703
-			'label_col'        => '',
704
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
705
-			'label_class'      => '',
706
-			'help_text'        => '',
707
-			'placeholder'      => '',
708
-			'options'          => array(),
709
-			// array or string
710
-			'icon'             => '',
711
-			'multiple'         => false,
712
-			'select2'          => false,
713
-			'no_wrap'          => false,
714
-			'input_group_right' => '',
715
-			'input_group_left' => '',
716
-			'input_group_right_inside' => false, // forces the input group inside the input
717
-			'input_group_left_inside' => false, // forces the input group inside the input
718
-			'element_require'  => '',
719
-			// [%element_id%] == "1"
720
-			'extra_attributes' => array(),
721
-			// an array of extra attributes
722
-			'wrap_attributes'  => array(),
723
-		);
724
-
725
-		/**
726
-		 * Parse incoming $args into an array and merge it with $defaults
727
-		 */
728
-		$args   = wp_parse_args( $args, $defaults );
729
-		$output = '';
730
-
731
-		// for now lets hide floating labels
732
-		if ( $args['label_type'] == 'floating' ) {
733
-			$args['label_type'] = 'hidden';
734
-		}
735
-
736
-		// hidden label option needs to be empty
737
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
738
-
739
-
740
-		$label_after = $args['label_after'];
741
-
742
-		// floating labels need label after
743
-		if ( $args['label_type'] == 'floating' ) {
744
-			$label_after         = true;
745
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
746
-		}
747
-
748
-		// Maybe setup select2
749
-		$is_select2 = false;
750
-		if ( ! empty( $args['select2'] ) ) {
751
-			$args['class'] .= ' aui-select2';
752
-			$is_select2 = true;
753
-		} elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
754
-			$is_select2 = true;
755
-		}
756
-
757
-		// select2 tags
758
-		if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
759
-			$args['data-tags']             = 'true';
760
-			$args['data-token-separators'] = "[',']";
761
-			$args['multiple']              = true;
762
-		}
763
-
764
-		// select2 placeholder
765
-		if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
766
-			$args['data-placeholder'] = esc_attr( $args['placeholder'] );
767
-			$args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
768
-		}
769
-
770
-
771
-
772
-		// maybe horizontal label
269
+            }
270
+
271
+            // input group wraps
272
+            if ( $args['input_group_left'] || $args['input_group_right'] ) {
273
+                $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
274
+                if ( $args['input_group_left'] ) {
275
+                    $output = self::wrap( array(
276
+                        'content'                 => $output,
277
+                        'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
278
+                        'input_group_left'        => $args['input_group_left'],
279
+                        'input_group_left_inside' => $args['input_group_left_inside']
280
+                    ) );
281
+                }
282
+                if ( $args['input_group_right'] ) {
283
+                    $output = self::wrap( array(
284
+                        'content'                  => $output,
285
+                        'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
286
+                        'input_group_right'        => $args['input_group_right'],
287
+                        'input_group_right_inside' => $args['input_group_right_inside']
288
+                    ) );
289
+                }
290
+
291
+            }
292
+
293
+            if ( ! $label_after ) {
294
+                $output .= $help_text;
295
+            }
296
+
297
+
298
+            if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
299
+                $output = self::wrap( array(
300
+                    'content' => $output,
301
+                    'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
302
+                ) );
303
+            }
304
+
305
+            if ( ! $label_after ) {
306
+                $output = $label . $output;
307
+            }
308
+
309
+            // wrap
310
+            if ( ! $args['no_wrap'] ) {
311
+                $form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
312
+                $wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
313
+                $wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
+                $output           = self::wrap( array(
315
+                    'content'         => $output,
316
+                    'class'           => $wrap_class,
317
+                    'element_require' => $args['element_require'],
318
+                    'argument_id'     => $args['id'],
319
+                    'wrap_attributes' => $args['wrap_attributes'],
320
+                ) );
321
+            }
322
+        }
323
+
324
+        return $output;
325
+    }
326
+
327
+    public static function label( $args = array(), $type = '' ) {
328
+        //<label for="exampleInputEmail1">Email address</label>
329
+        $defaults = array(
330
+            'title'      => 'div',
331
+            'for'        => '',
332
+            'class'      => '',
333
+            'label_type' => '', // empty = hidden, top, horizontal
334
+            'label_col'  => '',
335
+        );
336
+
337
+        /**
338
+         * Parse incoming $args into an array and merge it with $defaults
339
+         */
340
+        $args   = wp_parse_args( $args, $defaults );
341
+        $output = '';
342
+
343
+        if ( $args['title'] ) {
344
+
345
+            // maybe hide labels //@todo set a global option for visibility class
346
+            if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
347
+                $class = $args['class'];
348
+            } else {
349
+                $class = 'sr-only ' . $args['class'];
350
+            }
351
+
352
+            // maybe horizontal
353
+            if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
354
+                $class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label';
355
+            }
356
+
357
+            // open
358
+            $output .= '<label ';
359
+
360
+            // for
361
+            if ( ! empty( $args['for'] ) ) {
362
+                $output .= ' for="' . esc_attr( $args['for'] ) . '" ';
363
+            }
364
+
365
+            // class
366
+            $class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
367
+            $output .= ' class="' . $class . '" ';
368
+
369
+            // close
370
+            $output .= '>';
371
+
372
+
373
+            // title, don't escape fully as can contain html
374
+            if ( ! empty( $args['title'] ) ) {
375
+                $output .= wp_kses_post( $args['title'] );
376
+            }
377
+
378
+            // close wrap
379
+            $output .= '</label>';
380
+
381
+
382
+        }
383
+
384
+
385
+        return $output;
386
+    }
387
+
388
+    /**
389
+     * Wrap some content in a HTML wrapper.
390
+     *
391
+     * @param array $args
392
+     *
393
+     * @return string
394
+     */
395
+    public static function wrap( $args = array() ) {
396
+        $defaults = array(
397
+            'type'                     => 'div',
398
+            'class'                    => 'form-group',
399
+            'content'                  => '',
400
+            'input_group_left'         => '',
401
+            'input_group_right'        => '',
402
+            'input_group_left_inside'  => false,
403
+            'input_group_right_inside' => false,
404
+            'element_require'          => '',
405
+            'argument_id'              => '',
406
+            'wrap_attributes'          => array()
407
+        );
408
+
409
+        /**
410
+         * Parse incoming $args into an array and merge it with $defaults
411
+         */
412
+        $args   = wp_parse_args( $args, $defaults );
413
+        $output = '';
414
+        if ( $args['type'] ) {
415
+
416
+            // open
417
+            $output .= '<' . sanitize_html_class( $args['type'] );
418
+
419
+            // element require
420
+            if ( ! empty( $args['element_require'] ) ) {
421
+                $output .= AUI_Component_Helper::element_require( $args['element_require'] );
422
+                $args['class'] .= " aui-conditional-field";
423
+            }
424
+
425
+            // argument_id
426
+            if ( ! empty( $args['argument_id'] ) ) {
427
+                $output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
428
+            }
429
+
430
+            // class
431
+            $class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
432
+            $output .= ' class="' . $class . '" ';
433
+
434
+            // Attributes
435
+            if ( ! empty( $args['wrap_attributes'] ) ) {
436
+                $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
437
+            }
438
+
439
+            // close wrap
440
+            $output .= ' >';
441
+
442
+
443
+            // Input group left
444
+            if ( ! empty( $args['input_group_left'] ) ) {
445
+                $position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
446
+                $input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
447
+                $output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
448
+            }
449
+
450
+            // content
451
+            $output .= $args['content'];
452
+
453
+            // Input group right
454
+            if ( ! empty( $args['input_group_right'] ) ) {
455
+                $position_class    = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
456
+                $input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
457
+                $output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
458
+            }
459
+
460
+
461
+            // close wrap
462
+            $output .= '</' . sanitize_html_class( $args['type'] ) . '>';
463
+
464
+
465
+        } else {
466
+            $output = $args['content'];
467
+        }
468
+
469
+        return $output;
470
+    }
471
+
472
+    /**
473
+     * Build the component.
474
+     *
475
+     * @param array $args
476
+     *
477
+     * @return string The rendered component.
478
+     */
479
+    public static function textarea( $args = array() ) {
480
+        $defaults = array(
481
+            'name'               => '',
482
+            'class'              => '',
483
+            'wrap_class'         => '',
484
+            'id'                 => '',
485
+            'placeholder'        => '',
486
+            'title'              => '',
487
+            'value'              => '',
488
+            'required'           => false,
489
+            'label'              => '',
490
+            'label_after'        => false,
491
+            'label_class'        => '',
492
+            'label_type'         => '',
493
+            'label_col'          => '',
494
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
495
+            'help_text'          => '',
496
+            'validation_text'    => '',
497
+            'validation_pattern' => '',
498
+            'no_wrap'            => false,
499
+            'rows'               => '',
500
+            'wysiwyg'            => false,
501
+            'allow_tags'         => false,
502
+            // Allow HTML tags
503
+            'element_require'    => '',
504
+            // [%element_id%] == "1"
505
+            'extra_attributes'   => array(),
506
+            // an array of extra attributes
507
+            'wrap_attributes'    => array(),
508
+        );
509
+
510
+        /**
511
+         * Parse incoming $args into an array and merge it with $defaults
512
+         */
513
+        $args   = wp_parse_args( $args, $defaults );
514
+        $output = '';
515
+
516
+        // hidden label option needs to be empty
517
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
518
+
519
+        // floating labels don't work with wysiwyg so set it as top
520
+        if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
521
+            $args['label_type'] = 'top';
522
+        }
523
+
524
+        $label_after = $args['label_after'];
525
+
526
+        // floating labels need label after
527
+        if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
528
+            $label_after         = true;
529
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
530
+        }
531
+
532
+        // label
533
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
534
+        } elseif ( ! empty( $args['label'] ) && ! $label_after ) {
535
+            $label_args = array(
536
+                'title'      => $args['label'],
537
+                'for'        => $args['id'],
538
+                'class'      => $args['label_class'] . " ",
539
+                'label_type' => $args['label_type'],
540
+                'label_col'  => $args['label_col']
541
+            );
542
+            $output .= self::label( $label_args );
543
+        }
544
+
545
+        // maybe horizontal label
546
+        if ( $args['label_type'] == 'horizontal' ) {
547
+            $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
548
+            $output .= '<div class="' . $input_col . '">';
549
+        }
550
+
551
+        if ( ! empty( $args['wysiwyg'] ) ) {
552
+            ob_start();
553
+            $content   = $args['value'];
554
+            $editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
555
+            $settings  = array(
556
+                'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
557
+                'quicktags'     => false,
558
+                'media_buttons' => false,
559
+                'editor_class'  => 'form-control',
560
+                'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
561
+                'teeny'         => true,
562
+            );
563
+
564
+            // maybe set settings if array
565
+            if ( is_array( $args['wysiwyg'] ) ) {
566
+                $settings = wp_parse_args( $args['wysiwyg'], $settings );
567
+            }
568
+
569
+            wp_editor( $content, $editor_id, $settings );
570
+            $output .= ob_get_clean();
571
+        } else {
572
+
573
+            // open
574
+            $output .= '<textarea ';
575
+
576
+            // name
577
+            if ( ! empty( $args['name'] ) ) {
578
+                $output .= ' name="' . esc_attr( $args['name'] ) . '" ';
579
+            }
580
+
581
+            // id
582
+            if ( ! empty( $args['id'] ) ) {
583
+                $output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
584
+            }
585
+
586
+            // placeholder
587
+            if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
588
+                $output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
589
+            }
590
+
591
+            // title
592
+            if ( ! empty( $args['title'] ) ) {
593
+                $output .= ' title="' . esc_attr( $args['title'] ) . '" ';
594
+            }
595
+
596
+            // validation text
597
+            if ( ! empty( $args['validation_text'] ) ) {
598
+                $output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
599
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
600
+            }
601
+
602
+            // validation_pattern
603
+            if ( ! empty( $args['validation_pattern'] ) ) {
604
+                $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
605
+            }
606
+
607
+            // required
608
+            if ( ! empty( $args['required'] ) ) {
609
+                $output .= ' required ';
610
+            }
611
+
612
+            // rows
613
+            if ( ! empty( $args['rows'] ) ) {
614
+                $output .= ' rows="' . absint( $args['rows'] ) . '" ';
615
+            }
616
+
617
+
618
+            // class
619
+            $class = ! empty( $args['class'] ) ? $args['class'] : '';
620
+            $output .= ' class="form-control ' . $class . '" ';
621
+
622
+            // extra attributes
623
+            if ( ! empty( $args['extra_attributes'] ) ) {
624
+                $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
625
+            }
626
+
627
+            // close tag
628
+            $output .= ' >';
629
+
630
+            // value
631
+            if ( ! empty( $args['value'] ) ) {
632
+                if ( ! empty( $args['allow_tags'] ) ) {
633
+                    $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
634
+                } else {
635
+                    $output .= sanitize_textarea_field( $args['value'] );
636
+                }
637
+            }
638
+
639
+            // closing tag
640
+            $output .= '</textarea>';
641
+
642
+        }
643
+
644
+        if ( ! empty( $args['label'] ) && $label_after ) {
645
+            $label_args = array(
646
+                'title'      => $args['label'],
647
+                'for'        => $args['id'],
648
+                'class'      => $args['label_class'] . " ",
649
+                'label_type' => $args['label_type'],
650
+                'label_col'  => $args['label_col']
651
+            );
652
+            $output .= self::label( $label_args );
653
+        }
654
+
655
+        // help text
656
+        if ( ! empty( $args['help_text'] ) ) {
657
+            $output .= AUI_Component_Helper::help_text( $args['help_text'] );
658
+        }
659
+
660
+        // maybe horizontal label
661
+        if ( $args['label_type'] == 'horizontal' ) {
662
+            $output .= '</div>';
663
+        }
664
+
665
+
666
+        // wrap
667
+        if ( ! $args['no_wrap'] ) {
668
+            $form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
669
+            $wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
670
+            $wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
671
+            $output           = self::wrap( array(
672
+                'content'         => $output,
673
+                'class'           => $wrap_class,
674
+                'element_require' => $args['element_require'],
675
+                'argument_id'     => $args['id'],
676
+                'wrap_attributes' => $args['wrap_attributes'],
677
+            ) );
678
+        }
679
+
680
+
681
+        return $output;
682
+    }
683
+
684
+    /**
685
+     * Build the component.
686
+     *
687
+     * @param array $args
688
+     *
689
+     * @return string The rendered component.
690
+     */
691
+    public static function select( $args = array() ) {
692
+        $defaults = array(
693
+            'class'            => '',
694
+            'wrap_class'       => '',
695
+            'id'               => '',
696
+            'title'            => '',
697
+            'value'            => '',
698
+            // can be an array or a string
699
+            'required'         => false,
700
+            'label'            => '',
701
+            'label_after'      => false,
702
+            'label_type'       => '',
703
+            'label_col'        => '',
704
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
705
+            'label_class'      => '',
706
+            'help_text'        => '',
707
+            'placeholder'      => '',
708
+            'options'          => array(),
709
+            // array or string
710
+            'icon'             => '',
711
+            'multiple'         => false,
712
+            'select2'          => false,
713
+            'no_wrap'          => false,
714
+            'input_group_right' => '',
715
+            'input_group_left' => '',
716
+            'input_group_right_inside' => false, // forces the input group inside the input
717
+            'input_group_left_inside' => false, // forces the input group inside the input
718
+            'element_require'  => '',
719
+            // [%element_id%] == "1"
720
+            'extra_attributes' => array(),
721
+            // an array of extra attributes
722
+            'wrap_attributes'  => array(),
723
+        );
724
+
725
+        /**
726
+         * Parse incoming $args into an array and merge it with $defaults
727
+         */
728
+        $args   = wp_parse_args( $args, $defaults );
729
+        $output = '';
730
+
731
+        // for now lets hide floating labels
732
+        if ( $args['label_type'] == 'floating' ) {
733
+            $args['label_type'] = 'hidden';
734
+        }
735
+
736
+        // hidden label option needs to be empty
737
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
738
+
739
+
740
+        $label_after = $args['label_after'];
741
+
742
+        // floating labels need label after
743
+        if ( $args['label_type'] == 'floating' ) {
744
+            $label_after         = true;
745
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
746
+        }
747
+
748
+        // Maybe setup select2
749
+        $is_select2 = false;
750
+        if ( ! empty( $args['select2'] ) ) {
751
+            $args['class'] .= ' aui-select2';
752
+            $is_select2 = true;
753
+        } elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
754
+            $is_select2 = true;
755
+        }
756
+
757
+        // select2 tags
758
+        if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
759
+            $args['data-tags']             = 'true';
760
+            $args['data-token-separators'] = "[',']";
761
+            $args['multiple']              = true;
762
+        }
763
+
764
+        // select2 placeholder
765
+        if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
766
+            $args['data-placeholder'] = esc_attr( $args['placeholder'] );
767
+            $args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
768
+        }
769
+
770
+
771
+
772
+        // maybe horizontal label
773 773
 //		if ( $args['label_type'] == 'horizontal' ) {
774 774
 //			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
775 775
 //			$output .= '<div class="' . $input_col . '">';
776 776
 //		}
777 777
 
778
-		// Set hidden input to save empty value for multiselect.
779
-		if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
780
-			$output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>';
781
-		}
782
-
783
-		// open/type
784
-		$output .= '<select ';
785
-
786
-		// style
787
-		if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
788
-			$output .= " style='width:100%;' ";
789
-		}
790
-
791
-		// element require
792
-		if ( ! empty( $args['element_require'] ) ) {
793
-			$output .= AUI_Component_Helper::element_require( $args['element_require'] );
794
-			$args['class'] .= " aui-conditional-field";
795
-		}
796
-
797
-		// class
798
-		$class = ! empty( $args['class'] ) ? $args['class'] : '';
799
-		$output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class );
800
-
801
-		// name
802
-		if ( ! empty( $args['name'] ) ) {
803
-			$output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
804
-		}
805
-
806
-		// id
807
-		if ( ! empty( $args['id'] ) ) {
808
-			$output .= AUI_Component_Helper::id( $args['id'] );
809
-		}
810
-
811
-		// title
812
-		if ( ! empty( $args['title'] ) ) {
813
-			$output .= AUI_Component_Helper::title( $args['title'] );
814
-		}
815
-
816
-		// data-attributes
817
-		$output .= AUI_Component_Helper::data_attributes( $args );
818
-
819
-		// aria-attributes
820
-		$output .= AUI_Component_Helper::aria_attributes( $args );
821
-
822
-		// extra attributes
823
-		if ( ! empty( $args['extra_attributes'] ) ) {
824
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
825
-		}
826
-
827
-		// required
828
-		if ( ! empty( $args['required'] ) ) {
829
-			$output .= ' required ';
830
-		}
831
-
832
-		// multiple
833
-		if ( ! empty( $args['multiple'] ) ) {
834
-			$output .= ' multiple ';
835
-		}
836
-
837
-		// close opening tag
838
-		$output .= ' >';
839
-
840
-		// placeholder
841
-		if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
842
-			$output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
843
-		} elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
844
-			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
845
-		}
846
-
847
-		// Options
848
-		if ( ! empty( $args['options'] ) ) {
849
-
850
-			if ( ! is_array( $args['options'] ) ) {
851
-				$output .= $args['options']; // not the preferred way but an option
852
-			} else {
853
-				foreach ( $args['options'] as $val => $name ) {
854
-					$selected = '';
855
-					if ( is_array( $name ) ) {
856
-						if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
857
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
858
-
859
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
860
-						} else {
861
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
862
-							$option_value = isset( $name['value'] ) ? $name['value'] : '';
863
-							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
864
-							if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
865
-								$selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
866
-							} elseif ( ! empty( $args['value'] ) ) {
867
-								$selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
868
-							}
869
-
870
-							$output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
871
-						}
872
-					} else {
873
-						if ( ! empty( $args['value'] ) ) {
874
-							if ( is_array( $args['value'] ) ) {
875
-								$selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
876
-							} elseif ( ! empty( $args['value'] ) ) {
877
-								$selected = selected( $args['value'], $val, false );
878
-							}
879
-						}
880
-						$output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
881
-					}
882
-				}
883
-			}
884
-
885
-		}
886
-
887
-		// closing tag
888
-		$output .= '</select>';
889
-
890
-		$label = '';
891
-		$help_text = '';
892
-		// label
893
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
894
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
895
-			$label_args = array(
896
-				'title'      => $args['label'],
897
-				'for'        => $args['id'],
898
-				'class'      => $args['label_class'] . " ",
899
-				'label_type' => $args['label_type'],
900
-				'label_col'  => $args['label_col']
901
-			);
902
-			$label = self::label( $label_args );
903
-		}
904
-
905
-		// help text
906
-		if ( ! empty( $args['help_text'] ) ) {
907
-			$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
908
-		}
909
-
910
-		// input group wraps
911
-		if ( $args['input_group_left'] || $args['input_group_right'] ) {
912
-			$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
913
-			if ( $args['input_group_left'] ) {
914
-				$output = self::wrap( array(
915
-					'content'                 => $output,
916
-					'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
917
-					'input_group_left'        => $args['input_group_left'],
918
-					'input_group_left_inside' => $args['input_group_left_inside']
919
-				) );
920
-			}
921
-			if ( $args['input_group_right'] ) {
922
-				$output = self::wrap( array(
923
-					'content'                  => $output,
924
-					'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
925
-					'input_group_right'        => $args['input_group_right'],
926
-					'input_group_right_inside' => $args['input_group_right_inside']
927
-				) );
928
-			}
929
-
930
-		}
931
-
932
-		if ( ! $label_after ) {
933
-			$output .= $help_text;
934
-		}
935
-
936
-
937
-		if ( $args['label_type'] == 'horizontal' ) {
938
-			$output = self::wrap( array(
939
-				'content' => $output,
940
-				'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
941
-			) );
942
-		}
943
-
944
-		if ( ! $label_after ) {
945
-			$output = $label . $output;
946
-		}
947
-
948
-		// maybe horizontal label
778
+        // Set hidden input to save empty value for multiselect.
779
+        if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
780
+            $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>';
781
+        }
782
+
783
+        // open/type
784
+        $output .= '<select ';
785
+
786
+        // style
787
+        if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
788
+            $output .= " style='width:100%;' ";
789
+        }
790
+
791
+        // element require
792
+        if ( ! empty( $args['element_require'] ) ) {
793
+            $output .= AUI_Component_Helper::element_require( $args['element_require'] );
794
+            $args['class'] .= " aui-conditional-field";
795
+        }
796
+
797
+        // class
798
+        $class = ! empty( $args['class'] ) ? $args['class'] : '';
799
+        $output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class );
800
+
801
+        // name
802
+        if ( ! empty( $args['name'] ) ) {
803
+            $output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
804
+        }
805
+
806
+        // id
807
+        if ( ! empty( $args['id'] ) ) {
808
+            $output .= AUI_Component_Helper::id( $args['id'] );
809
+        }
810
+
811
+        // title
812
+        if ( ! empty( $args['title'] ) ) {
813
+            $output .= AUI_Component_Helper::title( $args['title'] );
814
+        }
815
+
816
+        // data-attributes
817
+        $output .= AUI_Component_Helper::data_attributes( $args );
818
+
819
+        // aria-attributes
820
+        $output .= AUI_Component_Helper::aria_attributes( $args );
821
+
822
+        // extra attributes
823
+        if ( ! empty( $args['extra_attributes'] ) ) {
824
+            $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
825
+        }
826
+
827
+        // required
828
+        if ( ! empty( $args['required'] ) ) {
829
+            $output .= ' required ';
830
+        }
831
+
832
+        // multiple
833
+        if ( ! empty( $args['multiple'] ) ) {
834
+            $output .= ' multiple ';
835
+        }
836
+
837
+        // close opening tag
838
+        $output .= ' >';
839
+
840
+        // placeholder
841
+        if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
842
+            $output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
843
+        } elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
844
+            $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
845
+        }
846
+
847
+        // Options
848
+        if ( ! empty( $args['options'] ) ) {
849
+
850
+            if ( ! is_array( $args['options'] ) ) {
851
+                $output .= $args['options']; // not the preferred way but an option
852
+            } else {
853
+                foreach ( $args['options'] as $val => $name ) {
854
+                    $selected = '';
855
+                    if ( is_array( $name ) ) {
856
+                        if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
857
+                            $option_label = isset( $name['label'] ) ? $name['label'] : '';
858
+
859
+                            $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
860
+                        } else {
861
+                            $option_label = isset( $name['label'] ) ? $name['label'] : '';
862
+                            $option_value = isset( $name['value'] ) ? $name['value'] : '';
863
+                            $extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
864
+                            if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
865
+                                $selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
866
+                            } elseif ( ! empty( $args['value'] ) ) {
867
+                                $selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
868
+                            }
869
+
870
+                            $output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
871
+                        }
872
+                    } else {
873
+                        if ( ! empty( $args['value'] ) ) {
874
+                            if ( is_array( $args['value'] ) ) {
875
+                                $selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
876
+                            } elseif ( ! empty( $args['value'] ) ) {
877
+                                $selected = selected( $args['value'], $val, false );
878
+                            }
879
+                        }
880
+                        $output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
881
+                    }
882
+                }
883
+            }
884
+
885
+        }
886
+
887
+        // closing tag
888
+        $output .= '</select>';
889
+
890
+        $label = '';
891
+        $help_text = '';
892
+        // label
893
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
894
+        } elseif ( ! empty( $args['label'] ) && ! $label_after ) {
895
+            $label_args = array(
896
+                'title'      => $args['label'],
897
+                'for'        => $args['id'],
898
+                'class'      => $args['label_class'] . " ",
899
+                'label_type' => $args['label_type'],
900
+                'label_col'  => $args['label_col']
901
+            );
902
+            $label = self::label( $label_args );
903
+        }
904
+
905
+        // help text
906
+        if ( ! empty( $args['help_text'] ) ) {
907
+            $help_text = AUI_Component_Helper::help_text( $args['help_text'] );
908
+        }
909
+
910
+        // input group wraps
911
+        if ( $args['input_group_left'] || $args['input_group_right'] ) {
912
+            $w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
913
+            if ( $args['input_group_left'] ) {
914
+                $output = self::wrap( array(
915
+                    'content'                 => $output,
916
+                    'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
917
+                    'input_group_left'        => $args['input_group_left'],
918
+                    'input_group_left_inside' => $args['input_group_left_inside']
919
+                ) );
920
+            }
921
+            if ( $args['input_group_right'] ) {
922
+                $output = self::wrap( array(
923
+                    'content'                  => $output,
924
+                    'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
925
+                    'input_group_right'        => $args['input_group_right'],
926
+                    'input_group_right_inside' => $args['input_group_right_inside']
927
+                ) );
928
+            }
929
+
930
+        }
931
+
932
+        if ( ! $label_after ) {
933
+            $output .= $help_text;
934
+        }
935
+
936
+
937
+        if ( $args['label_type'] == 'horizontal' ) {
938
+            $output = self::wrap( array(
939
+                'content' => $output,
940
+                'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
941
+            ) );
942
+        }
943
+
944
+        if ( ! $label_after ) {
945
+            $output = $label . $output;
946
+        }
947
+
948
+        // maybe horizontal label
949 949
 //		if ( $args['label_type'] == 'horizontal' ) {
950 950
 //			$output .= '</div>';
951 951
 //		}
952 952
 
953 953
 
954
-		// wrap
955
-		if ( ! $args['no_wrap'] ) {
956
-			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
957
-			$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
958
-			$output     = self::wrap( array(
959
-				'content'         => $output,
960
-				'class'           => $wrap_class,
961
-				'element_require' => $args['element_require'],
962
-				'argument_id'     => $args['id'],
963
-				'wrap_attributes' => $args['wrap_attributes'],
964
-			) );
965
-		}
966
-
967
-
968
-		return $output;
969
-	}
970
-
971
-	/**
972
-	 * Build the component.
973
-	 *
974
-	 * @param array $args
975
-	 *
976
-	 * @return string The rendered component.
977
-	 */
978
-	public static function radio( $args = array() ) {
979
-		$defaults = array(
980
-			'class'            => '',
981
-			'wrap_class'       => '',
982
-			'id'               => '',
983
-			'title'            => '',
984
-			'horizontal'       => false,
985
-			// sets the lable horizontal
986
-			'value'            => '',
987
-			'label'            => '',
988
-			'label_class'      => '',
989
-			'label_type'       => '',
990
-			'label_col'        => '',
991
-			// sets the label type, default: hidden. Options: hidden, top, horizontal, floating
992
-			'help_text'        => '',
993
-			'inline'           => true,
994
-			'required'         => false,
995
-			'options'          => array(),
996
-			'icon'             => '',
997
-			'no_wrap'          => false,
998
-			'element_require'  => '',
999
-			// [%element_id%] == "1"
1000
-			'extra_attributes' => array(),
1001
-			// an array of extra attributes
1002
-			'wrap_attributes'  => array()
1003
-		);
1004
-
1005
-		/**
1006
-		 * Parse incoming $args into an array and merge it with $defaults
1007
-		 */
1008
-		$args = wp_parse_args( $args, $defaults );
1009
-
1010
-		// for now lets use horizontal for floating
1011
-		if ( $args['label_type'] == 'floating' ) {
1012
-			$args['label_type'] = 'horizontal';
1013
-		}
1014
-
1015
-		$label_args = array(
1016
-			'title'      => $args['label'],
1017
-			'class'      => $args['label_class'] . " pt-0 ",
1018
-			'label_type' => $args['label_type'],
1019
-			'label_col'  => $args['label_col']
1020
-		);
1021
-
1022
-		$output = '';
1023
-
1024
-
1025
-		// label before
1026
-		if ( ! empty( $args['label'] ) ) {
1027
-			$output .= self::label( $label_args, 'radio' );
1028
-		}
1029
-
1030
-		// maybe horizontal label
1031
-		if ( $args['label_type'] == 'horizontal' ) {
1032
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1033
-			$output .= '<div class="' . $input_col . '">';
1034
-		}
1035
-
1036
-		if ( ! empty( $args['options'] ) ) {
1037
-			$count = 0;
1038
-			foreach ( $args['options'] as $value => $label ) {
1039
-				$option_args            = $args;
1040
-				$option_args['value']   = $value;
1041
-				$option_args['label']   = $label;
1042
-				$option_args['checked'] = $value == $args['value'] ? true : false;
1043
-				$output .= self::radio_option( $option_args, $count );
1044
-				$count ++;
1045
-			}
1046
-		}
1047
-
1048
-		// help text
1049
-		$help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1050
-		$output .= $help_text;
1051
-
1052
-		// maybe horizontal label
1053
-		if ( $args['label_type'] == 'horizontal' ) {
1054
-			$output .= '</div>';
1055
-		}
1056
-
1057
-		// wrap
1058
-		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
1059
-		$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1060
-		$output     = self::wrap( array(
1061
-			'content'         => $output,
1062
-			'class'           => $wrap_class,
1063
-			'element_require' => $args['element_require'],
1064
-			'argument_id'     => $args['id'],
1065
-			'wrap_attributes' => $args['wrap_attributes'],
1066
-		) );
1067
-
1068
-
1069
-		return $output;
1070
-	}
1071
-
1072
-	/**
1073
-	 * Build the component.
1074
-	 *
1075
-	 * @param array $args
1076
-	 *
1077
-	 * @return string The rendered component.
1078
-	 */
1079
-	public static function radio_option( $args = array(), $count = '' ) {
1080
-		$defaults = array(
1081
-			'class'            => '',
1082
-			'id'               => '',
1083
-			'title'            => '',
1084
-			'value'            => '',
1085
-			'required'         => false,
1086
-			'inline'           => true,
1087
-			'label'            => '',
1088
-			'options'          => array(),
1089
-			'icon'             => '',
1090
-			'no_wrap'          => false,
1091
-			'extra_attributes' => array() // an array of extra attributes
1092
-		);
1093
-
1094
-		/**
1095
-		 * Parse incoming $args into an array and merge it with $defaults
1096
-		 */
1097
-		$args = wp_parse_args( $args, $defaults );
1098
-
1099
-		$output = '';
1100
-
1101
-		// open/type
1102
-		$output .= '<input type="radio"';
1103
-
1104
-		// class
1105
-		$output .= ' class="form-check-input" ';
1106
-
1107
-		// name
1108
-		if ( ! empty( $args['name'] ) ) {
1109
-			$output .= AUI_Component_Helper::name( $args['name'] );
1110
-		}
1111
-
1112
-		// id
1113
-		if ( ! empty( $args['id'] ) ) {
1114
-			$output .= AUI_Component_Helper::id( $args['id'] . $count );
1115
-		}
1116
-
1117
-		// title
1118
-		if ( ! empty( $args['title'] ) ) {
1119
-			$output .= AUI_Component_Helper::title( $args['title'] );
1120
-		}
1121
-
1122
-		// value
1123
-		if ( isset( $args['value'] ) ) {
1124
-			$output .= AUI_Component_Helper::value( $args['value'] );
1125
-		}
1126
-
1127
-		// checked, for radio and checkboxes
1128
-		if ( $args['checked'] ) {
1129
-			$output .= ' checked ';
1130
-		}
1131
-
1132
-		// data-attributes
1133
-		$output .= AUI_Component_Helper::data_attributes( $args );
1134
-
1135
-		// aria-attributes
1136
-		$output .= AUI_Component_Helper::aria_attributes( $args );
1137
-
1138
-		// extra attributes
1139
-		if ( ! empty( $args['extra_attributes'] ) ) {
1140
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1141
-		}
1142
-
1143
-		// required
1144
-		if ( ! empty( $args['required'] ) ) {
1145
-			$output .= ' required ';
1146
-		}
1147
-
1148
-		// close opening tag
1149
-		$output .= ' >';
1150
-
1151
-		// label
1152
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1153
-		} elseif ( ! empty( $args['label'] ) ) {
1154
-			$output .= self::label( array(
1155
-				'title' => $args['label'],
1156
-				'for'   => $args['id'] . $count,
1157
-				'class' => 'form-check-label'
1158
-			), 'radio' );
1159
-		}
1160
-
1161
-		// wrap
1162
-		if ( ! $args['no_wrap'] ) {
1163
-			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1164
-
1165
-			// Unique wrap class
1166
-			$uniq_class = 'fwrap';
1167
-			if ( ! empty( $args['name'] ) ) {
1168
-				$uniq_class .= '-' . $args['name'];
1169
-			} else if ( ! empty( $args['id'] ) ) {
1170
-				$uniq_class .= '-' . $args['id'];
1171
-			}
1172
-
1173
-			if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1174
-				$uniq_class .= '-' . $args['value'];
1175
-			} else {
1176
-				$uniq_class .= '-' . $count;
1177
-			}
1178
-			$wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1179
-
1180
-			$output = self::wrap( array(
1181
-				'content' => $output,
1182
-				'class'   => $wrap_class
1183
-			) );
1184
-		}
1185
-
1186
-		return $output;
1187
-	}
954
+        // wrap
955
+        if ( ! $args['no_wrap'] ) {
956
+            $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
957
+            $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
958
+            $output     = self::wrap( array(
959
+                'content'         => $output,
960
+                'class'           => $wrap_class,
961
+                'element_require' => $args['element_require'],
962
+                'argument_id'     => $args['id'],
963
+                'wrap_attributes' => $args['wrap_attributes'],
964
+            ) );
965
+        }
966
+
967
+
968
+        return $output;
969
+    }
970
+
971
+    /**
972
+     * Build the component.
973
+     *
974
+     * @param array $args
975
+     *
976
+     * @return string The rendered component.
977
+     */
978
+    public static function radio( $args = array() ) {
979
+        $defaults = array(
980
+            'class'            => '',
981
+            'wrap_class'       => '',
982
+            'id'               => '',
983
+            'title'            => '',
984
+            'horizontal'       => false,
985
+            // sets the lable horizontal
986
+            'value'            => '',
987
+            'label'            => '',
988
+            'label_class'      => '',
989
+            'label_type'       => '',
990
+            'label_col'        => '',
991
+            // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
992
+            'help_text'        => '',
993
+            'inline'           => true,
994
+            'required'         => false,
995
+            'options'          => array(),
996
+            'icon'             => '',
997
+            'no_wrap'          => false,
998
+            'element_require'  => '',
999
+            // [%element_id%] == "1"
1000
+            'extra_attributes' => array(),
1001
+            // an array of extra attributes
1002
+            'wrap_attributes'  => array()
1003
+        );
1004
+
1005
+        /**
1006
+         * Parse incoming $args into an array and merge it with $defaults
1007
+         */
1008
+        $args = wp_parse_args( $args, $defaults );
1009
+
1010
+        // for now lets use horizontal for floating
1011
+        if ( $args['label_type'] == 'floating' ) {
1012
+            $args['label_type'] = 'horizontal';
1013
+        }
1014
+
1015
+        $label_args = array(
1016
+            'title'      => $args['label'],
1017
+            'class'      => $args['label_class'] . " pt-0 ",
1018
+            'label_type' => $args['label_type'],
1019
+            'label_col'  => $args['label_col']
1020
+        );
1021
+
1022
+        $output = '';
1023
+
1024
+
1025
+        // label before
1026
+        if ( ! empty( $args['label'] ) ) {
1027
+            $output .= self::label( $label_args, 'radio' );
1028
+        }
1029
+
1030
+        // maybe horizontal label
1031
+        if ( $args['label_type'] == 'horizontal' ) {
1032
+            $input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1033
+            $output .= '<div class="' . $input_col . '">';
1034
+        }
1035
+
1036
+        if ( ! empty( $args['options'] ) ) {
1037
+            $count = 0;
1038
+            foreach ( $args['options'] as $value => $label ) {
1039
+                $option_args            = $args;
1040
+                $option_args['value']   = $value;
1041
+                $option_args['label']   = $label;
1042
+                $option_args['checked'] = $value == $args['value'] ? true : false;
1043
+                $output .= self::radio_option( $option_args, $count );
1044
+                $count ++;
1045
+            }
1046
+        }
1047
+
1048
+        // help text
1049
+        $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1050
+        $output .= $help_text;
1051
+
1052
+        // maybe horizontal label
1053
+        if ( $args['label_type'] == 'horizontal' ) {
1054
+            $output .= '</div>';
1055
+        }
1056
+
1057
+        // wrap
1058
+        $wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
1059
+        $wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1060
+        $output     = self::wrap( array(
1061
+            'content'         => $output,
1062
+            'class'           => $wrap_class,
1063
+            'element_require' => $args['element_require'],
1064
+            'argument_id'     => $args['id'],
1065
+            'wrap_attributes' => $args['wrap_attributes'],
1066
+        ) );
1067
+
1068
+
1069
+        return $output;
1070
+    }
1071
+
1072
+    /**
1073
+     * Build the component.
1074
+     *
1075
+     * @param array $args
1076
+     *
1077
+     * @return string The rendered component.
1078
+     */
1079
+    public static function radio_option( $args = array(), $count = '' ) {
1080
+        $defaults = array(
1081
+            'class'            => '',
1082
+            'id'               => '',
1083
+            'title'            => '',
1084
+            'value'            => '',
1085
+            'required'         => false,
1086
+            'inline'           => true,
1087
+            'label'            => '',
1088
+            'options'          => array(),
1089
+            'icon'             => '',
1090
+            'no_wrap'          => false,
1091
+            'extra_attributes' => array() // an array of extra attributes
1092
+        );
1093
+
1094
+        /**
1095
+         * Parse incoming $args into an array and merge it with $defaults
1096
+         */
1097
+        $args = wp_parse_args( $args, $defaults );
1098
+
1099
+        $output = '';
1100
+
1101
+        // open/type
1102
+        $output .= '<input type="radio"';
1103
+
1104
+        // class
1105
+        $output .= ' class="form-check-input" ';
1106
+
1107
+        // name
1108
+        if ( ! empty( $args['name'] ) ) {
1109
+            $output .= AUI_Component_Helper::name( $args['name'] );
1110
+        }
1111
+
1112
+        // id
1113
+        if ( ! empty( $args['id'] ) ) {
1114
+            $output .= AUI_Component_Helper::id( $args['id'] . $count );
1115
+        }
1116
+
1117
+        // title
1118
+        if ( ! empty( $args['title'] ) ) {
1119
+            $output .= AUI_Component_Helper::title( $args['title'] );
1120
+        }
1121
+
1122
+        // value
1123
+        if ( isset( $args['value'] ) ) {
1124
+            $output .= AUI_Component_Helper::value( $args['value'] );
1125
+        }
1126
+
1127
+        // checked, for radio and checkboxes
1128
+        if ( $args['checked'] ) {
1129
+            $output .= ' checked ';
1130
+        }
1131
+
1132
+        // data-attributes
1133
+        $output .= AUI_Component_Helper::data_attributes( $args );
1134
+
1135
+        // aria-attributes
1136
+        $output .= AUI_Component_Helper::aria_attributes( $args );
1137
+
1138
+        // extra attributes
1139
+        if ( ! empty( $args['extra_attributes'] ) ) {
1140
+            $output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1141
+        }
1142
+
1143
+        // required
1144
+        if ( ! empty( $args['required'] ) ) {
1145
+            $output .= ' required ';
1146
+        }
1147
+
1148
+        // close opening tag
1149
+        $output .= ' >';
1150
+
1151
+        // label
1152
+        if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1153
+        } elseif ( ! empty( $args['label'] ) ) {
1154
+            $output .= self::label( array(
1155
+                'title' => $args['label'],
1156
+                'for'   => $args['id'] . $count,
1157
+                'class' => 'form-check-label'
1158
+            ), 'radio' );
1159
+        }
1160
+
1161
+        // wrap
1162
+        if ( ! $args['no_wrap'] ) {
1163
+            $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1164
+
1165
+            // Unique wrap class
1166
+            $uniq_class = 'fwrap';
1167
+            if ( ! empty( $args['name'] ) ) {
1168
+                $uniq_class .= '-' . $args['name'];
1169
+            } else if ( ! empty( $args['id'] ) ) {
1170
+                $uniq_class .= '-' . $args['id'];
1171
+            }
1172
+
1173
+            if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1174
+                $uniq_class .= '-' . $args['value'];
1175
+            } else {
1176
+                $uniq_class .= '-' . $count;
1177
+            }
1178
+            $wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1179
+
1180
+            $output = self::wrap( array(
1181
+                'content' => $output,
1182
+                'class'   => $wrap_class
1183
+            ) );
1184
+        }
1185
+
1186
+        return $output;
1187
+    }
1188 1188
 
1189 1189
 }
1190 1190
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +272 added lines, -272 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function input( $args = array() ) {
21
+	public static function input($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'                     => 'text',
24 24
 			'name'                     => '',
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 		/**
64 64
 		 * Parse incoming $args into an array and merge it with $defaults
65 65
 		 */
66
-		$args   = wp_parse_args( $args, $defaults );
66
+		$args   = wp_parse_args($args, $defaults);
67 67
 		$output = '';
68
-		if ( ! empty( $args['type'] ) ) {
68
+		if (!empty($args['type'])) {
69 69
 			// hidden label option needs to be empty
70 70
 			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
71 71
 
72
-			$type = sanitize_html_class( $args['type'] );
72
+			$type = sanitize_html_class($args['type']);
73 73
 
74 74
 			$help_text   = '';
75 75
 			$label       = '';
@@ -83,19 +83,19 @@  discard block
 block discarded – undo
83 83
 			);
84 84
 
85 85
 			// floating labels need label after
86
-			if ( $args['label_type'] == 'floating' && $type != 'checkbox' ) {
86
+			if ($args['label_type'] == 'floating' && $type != 'checkbox') {
87 87
 				$label_after         = true;
88 88
 				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
89 89
 			}
90 90
 
91 91
 			// Some special sauce for files
92
-			if ( $type == 'file' ) {
92
+			if ($type == 'file') {
93 93
 				$label_after = true; // if type file we need the label after
94 94
 				$args['class'] .= ' custom-file-input ';
95
-			} elseif ( $type == 'checkbox' ) {
95
+			} elseif ($type == 'checkbox') {
96 96
 				$label_after = true; // if type file we need the label after
97 97
 				$args['class'] .= ' custom-control-input ';
98
-			} elseif ( $type == 'datepicker' || $type == 'timepicker' ) {
98
+			} elseif ($type == 'datepicker' || $type == 'timepicker') {
99 99
 				$type = 'text';
100 100
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
101 101
 				$args['class'] .= ' bg-initial ';
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 				// enqueue the script
105 105
 				$aui_settings = AyeCode_UI_Settings::instance();
106 106
 				$aui_settings->enqueue_flatpickr();
107
-			} elseif ( $type == 'iconpicker' ) {
107
+			} elseif ($type == 'iconpicker') {
108 108
 				$type = 'text';
109 109
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
110 110
 //				$args['class'] .= ' bg-initial ';
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 				$aui_settings->enqueue_iconpicker();
120 120
 			}
121 121
 
122
-			if ( $type == 'checkbox' && !empty($args['name'] ) && strpos($args['name'], '[') === false ) {
123
-				$output .= '<input type="hidden" name="' . esc_attr( $args['name'] ) . '" value="0" />';
122
+			if ($type == 'checkbox' && !empty($args['name']) && strpos($args['name'], '[') === false) {
123
+				$output .= '<input type="hidden" name="' . esc_attr($args['name']) . '" value="0" />';
124 124
 			}
125 125
 
126 126
 
@@ -128,88 +128,88 @@  discard block
 block discarded – undo
128 128
 			$output .= '<input type="' . $type . '" ';
129 129
 
130 130
 			// name
131
-			if ( ! empty( $args['name'] ) ) {
132
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
131
+			if (!empty($args['name'])) {
132
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
133 133
 			}
134 134
 
135 135
 			// id
136
-			if ( ! empty( $args['id'] ) ) {
137
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
136
+			if (!empty($args['id'])) {
137
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
138 138
 			}
139 139
 
140 140
 			// placeholder
141
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
142
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
141
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
142
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
143 143
 			}
144 144
 
145 145
 			// title
146
-			if ( ! empty( $args['title'] ) ) {
147
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
146
+			if (!empty($args['title'])) {
147
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
148 148
 			}
149 149
 
150 150
 			// value
151
-			if ( ! empty( $args['value'] ) ) {
152
-				$output .= AUI_Component_Helper::value( $args['value'] );
151
+			if (!empty($args['value'])) {
152
+				$output .= AUI_Component_Helper::value($args['value']);
153 153
 			}
154 154
 
155 155
 			// checked, for radio and checkboxes
156
-			if ( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ) {
156
+			if (($type == 'checkbox' || $type == 'radio') && $args['checked']) {
157 157
 				$output .= ' checked ';
158 158
 			}
159 159
 
160 160
 			// validation text
161
-			if ( ! empty( $args['validation_text'] ) ) {
162
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
161
+			if (!empty($args['validation_text'])) {
162
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
163 163
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
164 164
 			}
165 165
 
166 166
 			// validation_pattern
167
-			if ( ! empty( $args['validation_pattern'] ) ) {
168
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
167
+			if (!empty($args['validation_pattern'])) {
168
+				$output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" ';
169 169
 			}
170 170
 
171 171
 			// step (for numbers)
172
-			if ( ! empty( $args['step'] ) ) {
172
+			if (!empty($args['step'])) {
173 173
 				$output .= ' step="' . $args['step'] . '" ';
174 174
 			}
175 175
 
176 176
 			// required
177
-			if ( ! empty( $args['required'] ) ) {
177
+			if (!empty($args['required'])) {
178 178
 				$output .= ' required ';
179 179
 			}
180 180
 
181 181
 			// class
182
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
182
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
183 183
 			$output .= ' class="form-control ' . $class . '" ';
184 184
 
185 185
 			// data-attributes
186
-			$output .= AUI_Component_Helper::data_attributes( $args );
186
+			$output .= AUI_Component_Helper::data_attributes($args);
187 187
 
188 188
 			// extra attributes
189
-			if ( ! empty( $args['extra_attributes'] ) ) {
190
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
189
+			if (!empty($args['extra_attributes'])) {
190
+				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
191 191
 			}
192 192
 
193 193
 			// close
194 194
 			$output .= ' >';
195 195
 
196 196
 			// help text
197
-			if ( ! empty( $args['help_text'] ) ) {
198
-				$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
197
+			if (!empty($args['help_text'])) {
198
+				$help_text = AUI_Component_Helper::help_text($args['help_text']);
199 199
 			}
200 200
 
201 201
 			// label
202
-			if ( ! empty( $args['label'] ) ) {
202
+			if (!empty($args['label'])) {
203 203
 				$label_base_class = '';
204
-				if ( $type == 'file' ) {
204
+				if ($type == 'file') {
205 205
 					$label_base_class = ' custom-file-label';
206
-				} elseif ( $type == 'checkbox' ) {
207
-					if ( ! empty( $args['label_force_left'] ) ) {
208
-						$label_args['title'] = wp_kses_post( $args['help_text'] );
206
+				} elseif ($type == 'checkbox') {
207
+					if (!empty($args['label_force_left'])) {
208
+						$label_args['title'] = wp_kses_post($args['help_text']);
209 209
 						$help_text = '';
210 210
 						//$label_args['class'] .= ' d-inline ';
211 211
 						$args['wrap_class'] .= ' align-items-center ';
212
-					}else{
212
+					} else {
213 213
 
214 214
 					}
215 215
 
@@ -217,45 +217,45 @@  discard block
 block discarded – undo
217 217
 				}
218 218
 				$label_args['class'] .= $label_base_class;
219 219
 				$temp_label_args = $label_args;
220
-				if(! empty( $args['label_force_left'] )){$temp_label_args['class'] = $label_base_class." text-muted";}
221
-				$label = self::label( $temp_label_args, $type );
220
+				if (!empty($args['label_force_left'])) {$temp_label_args['class'] = $label_base_class . " text-muted"; }
221
+				$label = self::label($temp_label_args, $type);
222 222
 			}
223 223
 
224 224
 
225 225
 
226 226
 
227 227
 			// set help text in the correct position
228
-			if ( $label_after ) {
228
+			if ($label_after) {
229 229
 				$output .= $label . $help_text;
230 230
 			}
231 231
 
232 232
 			// some input types need a separate wrap
233
-			if ( $type == 'file' ) {
234
-				$output = self::wrap( array(
233
+			if ($type == 'file') {
234
+				$output = self::wrap(array(
235 235
 					'content' => $output,
236 236
 					'class'   => 'form-group custom-file'
237
-				) );
238
-			} elseif ( $type == 'checkbox' ) {
237
+				));
238
+			} elseif ($type == 'checkbox') {
239 239
 
240 240
 				$label_args['title'] = $args['label'];
241
-				$label_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'label' );
242
-				$label = !empty( $args['label_force_left'] ) ? self::label( $label_args, 'cb' ) : '<div class="' . $label_col . ' col-form-label"></div>';
243
-				$switch_size_class = $args['switch'] && !is_bool( $args['switch'] ) ? ' custom-switch-'.esc_attr( $args['switch'] ) : '';
244
-				$wrap_class = $args['switch'] ? 'custom-switch'.$switch_size_class : 'custom-checkbox';
245
-				if ( ! empty( $args['label_force_left'] ) ) {
241
+				$label_col = AUI_Component_Helper::get_column_class($args['label_col'], 'label');
242
+				$label = !empty($args['label_force_left']) ? self::label($label_args, 'cb') : '<div class="' . $label_col . ' col-form-label"></div>';
243
+				$switch_size_class = $args['switch'] && !is_bool($args['switch']) ? ' custom-switch-' . esc_attr($args['switch']) : '';
244
+				$wrap_class = $args['switch'] ? 'custom-switch' . $switch_size_class : 'custom-checkbox';
245
+				if (!empty($args['label_force_left'])) {
246 246
 					$wrap_class .= ' d-flex align-content-center';
247
-					$label = str_replace("custom-control-label","", self::label( $label_args, 'cb' ) );
247
+					$label = str_replace("custom-control-label", "", self::label($label_args, 'cb'));
248 248
 				}
249
-				$output     = self::wrap( array(
249
+				$output = self::wrap(array(
250 250
 					'content' => $output,
251 251
 					'class'   => 'custom-control ' . $wrap_class
252
-				) );
252
+				));
253 253
 
254
-				if ( $args['label_type'] == 'horizontal' ) {
255
-					$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
254
+				if ($args['label_type'] == 'horizontal') {
255
+					$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
256 256
 					$output    = $label . '<div class="' . $input_col . '">' . $output . '</div>';
257 257
 				}
258
-			} elseif ( $type == 'password' && $args['password_toggle'] && ! $args['input_group_right'] ) {
258
+			} elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) {
259 259
 
260 260
 
261 261
 				// allow password field to toggle view
@@ -269,62 +269,62 @@  discard block
 block discarded – undo
269 269
 			}
270 270
 
271 271
 			// input group wraps
272
-			if ( $args['input_group_left'] || $args['input_group_right'] ) {
273
-				$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
274
-				if ( $args['input_group_left'] ) {
275
-					$output = self::wrap( array(
272
+			if ($args['input_group_left'] || $args['input_group_right']) {
273
+				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
274
+				if ($args['input_group_left']) {
275
+					$output = self::wrap(array(
276 276
 						'content'                 => $output,
277 277
 						'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
278 278
 						'input_group_left'        => $args['input_group_left'],
279 279
 						'input_group_left_inside' => $args['input_group_left_inside']
280
-					) );
280
+					));
281 281
 				}
282
-				if ( $args['input_group_right'] ) {
283
-					$output = self::wrap( array(
282
+				if ($args['input_group_right']) {
283
+					$output = self::wrap(array(
284 284
 						'content'                  => $output,
285 285
 						'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
286 286
 						'input_group_right'        => $args['input_group_right'],
287 287
 						'input_group_right_inside' => $args['input_group_right_inside']
288
-					) );
288
+					));
289 289
 				}
290 290
 
291 291
 			}
292 292
 
293
-			if ( ! $label_after ) {
293
+			if (!$label_after) {
294 294
 				$output .= $help_text;
295 295
 			}
296 296
 
297 297
 
298
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
299
-				$output = self::wrap( array(
298
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
299
+				$output = self::wrap(array(
300 300
 					'content' => $output,
301
-					'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
302
-				) );
301
+					'class'   => AUI_Component_Helper::get_column_class($args['label_col'], 'input')
302
+				));
303 303
 			}
304 304
 
305
-			if ( ! $label_after ) {
305
+			if (!$label_after) {
306 306
 				$output = $label . $output;
307 307
 			}
308 308
 
309 309
 			// wrap
310
-			if ( ! $args['no_wrap'] ) {
310
+			if (!$args['no_wrap']) {
311 311
 				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
312 312
 				$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
313
-				$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
-				$output           = self::wrap( array(
313
+				$wrap_class       = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
314
+				$output           = self::wrap(array(
315 315
 					'content'         => $output,
316 316
 					'class'           => $wrap_class,
317 317
 					'element_require' => $args['element_require'],
318 318
 					'argument_id'     => $args['id'],
319 319
 					'wrap_attributes' => $args['wrap_attributes'],
320
-				) );
320
+				));
321 321
 			}
322 322
 		}
323 323
 
324 324
 		return $output;
325 325
 	}
326 326
 
327
-	public static function label( $args = array(), $type = '' ) {
327
+	public static function label($args = array(), $type = '') {
328 328
 		//<label for="exampleInputEmail1">Email address</label>
329 329
 		$defaults = array(
330 330
 			'title'      => 'div',
@@ -337,33 +337,33 @@  discard block
 block discarded – undo
337 337
 		/**
338 338
 		 * Parse incoming $args into an array and merge it with $defaults
339 339
 		 */
340
-		$args   = wp_parse_args( $args, $defaults );
340
+		$args   = wp_parse_args($args, $defaults);
341 341
 		$output = '';
342 342
 
343
-		if ( $args['title'] ) {
343
+		if ($args['title']) {
344 344
 
345 345
 			// maybe hide labels //@todo set a global option for visibility class
346
-			if ( $type == 'file' || $type == 'checkbox' || $type == 'radio' || ! empty( $args['label_type'] ) ) {
346
+			if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) {
347 347
 				$class = $args['class'];
348 348
 			} else {
349 349
 				$class = 'sr-only ' . $args['class'];
350 350
 			}
351 351
 
352 352
 			// maybe horizontal
353
-			if ( $args['label_type'] == 'horizontal' && $type != 'checkbox' ) {
354
-				$class .= ' ' . AUI_Component_Helper::get_column_class( $args['label_col'], 'label' ) . ' col-form-label';
353
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
354
+				$class .= ' ' . AUI_Component_Helper::get_column_class($args['label_col'], 'label') . ' col-form-label';
355 355
 			}
356 356
 
357 357
 			// open
358 358
 			$output .= '<label ';
359 359
 
360 360
 			// for
361
-			if ( ! empty( $args['for'] ) ) {
362
-				$output .= ' for="' . esc_attr( $args['for'] ) . '" ';
361
+			if (!empty($args['for'])) {
362
+				$output .= ' for="' . esc_attr($args['for']) . '" ';
363 363
 			}
364 364
 
365 365
 			// class
366
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
366
+			$class = $class ? AUI_Component_Helper::esc_classes($class) : '';
367 367
 			$output .= ' class="' . $class . '" ';
368 368
 
369 369
 			// close
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 
372 372
 
373 373
 			// title, don't escape fully as can contain html
374
-			if ( ! empty( $args['title'] ) ) {
375
-				$output .= wp_kses_post( $args['title'] );
374
+			if (!empty($args['title'])) {
375
+				$output .= wp_kses_post($args['title']);
376 376
 			}
377 377
 
378 378
 			// close wrap
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	 *
393 393
 	 * @return string
394 394
 	 */
395
-	public static function wrap( $args = array() ) {
395
+	public static function wrap($args = array()) {
396 396
 		$defaults = array(
397 397
 			'type'                     => 'div',
398 398
 			'class'                    => 'form-group',
@@ -409,31 +409,31 @@  discard block
 block discarded – undo
409 409
 		/**
410 410
 		 * Parse incoming $args into an array and merge it with $defaults
411 411
 		 */
412
-		$args   = wp_parse_args( $args, $defaults );
412
+		$args   = wp_parse_args($args, $defaults);
413 413
 		$output = '';
414
-		if ( $args['type'] ) {
414
+		if ($args['type']) {
415 415
 
416 416
 			// open
417
-			$output .= '<' . sanitize_html_class( $args['type'] );
417
+			$output .= '<' . sanitize_html_class($args['type']);
418 418
 
419 419
 			// element require
420
-			if ( ! empty( $args['element_require'] ) ) {
421
-				$output .= AUI_Component_Helper::element_require( $args['element_require'] );
420
+			if (!empty($args['element_require'])) {
421
+				$output .= AUI_Component_Helper::element_require($args['element_require']);
422 422
 				$args['class'] .= " aui-conditional-field";
423 423
 			}
424 424
 
425 425
 			// argument_id
426
-			if ( ! empty( $args['argument_id'] ) ) {
427
-				$output .= ' data-argument="' . esc_attr( $args['argument_id'] ) . '"';
426
+			if (!empty($args['argument_id'])) {
427
+				$output .= ' data-argument="' . esc_attr($args['argument_id']) . '"';
428 428
 			}
429 429
 
430 430
 			// class
431
-			$class = ! empty( $args['class'] ) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
431
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
432 432
 			$output .= ' class="' . $class . '" ';
433 433
 
434 434
 			// Attributes
435
-			if ( ! empty( $args['wrap_attributes'] ) ) {
436
-				$output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
435
+			if (!empty($args['wrap_attributes'])) {
436
+				$output .= AUI_Component_Helper::extra_attributes($args['wrap_attributes']);
437 437
 			}
438 438
 
439 439
 			// close wrap
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
 
442 442
 
443 443
 			// Input group left
444
-			if ( ! empty( $args['input_group_left'] ) ) {
445
-				$position_class   = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
446
-				$input_group_left = strpos( $args['input_group_left'], '<' ) !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
444
+			if (!empty($args['input_group_left'])) {
445
+				$position_class   = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
446
+				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
447 447
 				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
448 448
 			}
449 449
 
@@ -451,15 +451,15 @@  discard block
 block discarded – undo
451 451
 			$output .= $args['content'];
452 452
 
453 453
 			// Input group right
454
-			if ( ! empty( $args['input_group_right'] ) ) {
455
-				$position_class    = ! empty( $args['input_group_left_inside'] ) ? 'position-absolute h-100' : '';
456
-				$input_group_right = strpos( $args['input_group_right'], '<' ) !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
454
+			if (!empty($args['input_group_right'])) {
455
+				$position_class    = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
456
+				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
457 457
 				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
458 458
 			}
459 459
 
460 460
 
461 461
 			// close wrap
462
-			$output .= '</' . sanitize_html_class( $args['type'] ) . '>';
462
+			$output .= '</' . sanitize_html_class($args['type']) . '>';
463 463
 
464 464
 
465 465
 		} else {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 *
477 477
 	 * @return string The rendered component.
478 478
 	 */
479
-	public static function textarea( $args = array() ) {
479
+	public static function textarea($args = array()) {
480 480
 		$defaults = array(
481 481
 			'name'               => '',
482 482
 			'class'              => '',
@@ -510,28 +510,28 @@  discard block
 block discarded – undo
510 510
 		/**
511 511
 		 * Parse incoming $args into an array and merge it with $defaults
512 512
 		 */
513
-		$args   = wp_parse_args( $args, $defaults );
513
+		$args   = wp_parse_args($args, $defaults);
514 514
 		$output = '';
515 515
 
516 516
 		// hidden label option needs to be empty
517 517
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
518 518
 
519 519
 		// floating labels don't work with wysiwyg so set it as top
520
-		if ( $args['label_type'] == 'floating' && ! empty( $args['wysiwyg'] ) ) {
520
+		if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) {
521 521
 			$args['label_type'] = 'top';
522 522
 		}
523 523
 
524 524
 		$label_after = $args['label_after'];
525 525
 
526 526
 		// floating labels need label after
527
-		if ( $args['label_type'] == 'floating' && empty( $args['wysiwyg'] ) ) {
527
+		if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) {
528 528
 			$label_after         = true;
529 529
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
530 530
 		}
531 531
 
532 532
 		// label
533
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
534
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
533
+		if (!empty($args['label']) && is_array($args['label'])) {
534
+		} elseif (!empty($args['label']) && !$label_after) {
535 535
 			$label_args = array(
536 536
 				'title'      => $args['label'],
537 537
 				'for'        => $args['id'],
@@ -539,34 +539,34 @@  discard block
 block discarded – undo
539 539
 				'label_type' => $args['label_type'],
540 540
 				'label_col'  => $args['label_col']
541 541
 			);
542
-			$output .= self::label( $label_args );
542
+			$output .= self::label($label_args);
543 543
 		}
544 544
 
545 545
 		// maybe horizontal label
546
-		if ( $args['label_type'] == 'horizontal' ) {
547
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
546
+		if ($args['label_type'] == 'horizontal') {
547
+			$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
548 548
 			$output .= '<div class="' . $input_col . '">';
549 549
 		}
550 550
 
551
-		if ( ! empty( $args['wysiwyg'] ) ) {
551
+		if (!empty($args['wysiwyg'])) {
552 552
 			ob_start();
553 553
 			$content   = $args['value'];
554
-			$editor_id = ! empty( $args['id'] ) ? sanitize_html_class( $args['id'] ) : 'wp_editor';
554
+			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
555 555
 			$settings  = array(
556
-				'textarea_rows' => ! empty( absint( $args['rows'] ) ) ? absint( $args['rows'] ) : 4,
556
+				'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
557 557
 				'quicktags'     => false,
558 558
 				'media_buttons' => false,
559 559
 				'editor_class'  => 'form-control',
560
-				'textarea_name' => ! empty( $args['name'] ) ? sanitize_html_class( $args['name'] ) : sanitize_html_class( $args['id'] ),
560
+				'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
561 561
 				'teeny'         => true,
562 562
 			);
563 563
 
564 564
 			// maybe set settings if array
565
-			if ( is_array( $args['wysiwyg'] ) ) {
566
-				$settings = wp_parse_args( $args['wysiwyg'], $settings );
565
+			if (is_array($args['wysiwyg'])) {
566
+				$settings = wp_parse_args($args['wysiwyg'], $settings);
567 567
 			}
568 568
 
569
-			wp_editor( $content, $editor_id, $settings );
569
+			wp_editor($content, $editor_id, $settings);
570 570
 			$output .= ob_get_clean();
571 571
 		} else {
572 572
 
@@ -574,65 +574,65 @@  discard block
 block discarded – undo
574 574
 			$output .= '<textarea ';
575 575
 
576 576
 			// name
577
-			if ( ! empty( $args['name'] ) ) {
578
-				$output .= ' name="' . esc_attr( $args['name'] ) . '" ';
577
+			if (!empty($args['name'])) {
578
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
579 579
 			}
580 580
 
581 581
 			// id
582
-			if ( ! empty( $args['id'] ) ) {
583
-				$output .= ' id="' . sanitize_html_class( $args['id'] ) . '" ';
582
+			if (!empty($args['id'])) {
583
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
584 584
 			}
585 585
 
586 586
 			// placeholder
587
-			if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] ) {
588
-				$output .= ' placeholder="' . esc_attr( $args['placeholder'] ) . '" ';
587
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
588
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
589 589
 			}
590 590
 
591 591
 			// title
592
-			if ( ! empty( $args['title'] ) ) {
593
-				$output .= ' title="' . esc_attr( $args['title'] ) . '" ';
592
+			if (!empty($args['title'])) {
593
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
594 594
 			}
595 595
 
596 596
 			// validation text
597
-			if ( ! empty( $args['validation_text'] ) ) {
598
-				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr( $args['validation_text'] ) . '\')" ';
597
+			if (!empty($args['validation_text'])) {
598
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
599 599
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
600 600
 			}
601 601
 
602 602
 			// validation_pattern
603
-			if ( ! empty( $args['validation_pattern'] ) ) {
604
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
603
+			if (!empty($args['validation_pattern'])) {
604
+				$output .= ' pattern="' . esc_attr($args['validation_pattern']) . '" ';
605 605
 			}
606 606
 
607 607
 			// required
608
-			if ( ! empty( $args['required'] ) ) {
608
+			if (!empty($args['required'])) {
609 609
 				$output .= ' required ';
610 610
 			}
611 611
 
612 612
 			// rows
613
-			if ( ! empty( $args['rows'] ) ) {
614
-				$output .= ' rows="' . absint( $args['rows'] ) . '" ';
613
+			if (!empty($args['rows'])) {
614
+				$output .= ' rows="' . absint($args['rows']) . '" ';
615 615
 			}
616 616
 
617 617
 
618 618
 			// class
619
-			$class = ! empty( $args['class'] ) ? $args['class'] : '';
619
+			$class = !empty($args['class']) ? $args['class'] : '';
620 620
 			$output .= ' class="form-control ' . $class . '" ';
621 621
 
622 622
 			// extra attributes
623
-			if ( ! empty( $args['extra_attributes'] ) ) {
624
-				$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
623
+			if (!empty($args['extra_attributes'])) {
624
+				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
625 625
 			}
626 626
 
627 627
 			// close tag
628 628
 			$output .= ' >';
629 629
 
630 630
 			// value
631
-			if ( ! empty( $args['value'] ) ) {
632
-				if ( ! empty( $args['allow_tags'] ) ) {
633
-					$output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
631
+			if (!empty($args['value'])) {
632
+				if (!empty($args['allow_tags'])) {
633
+					$output .= AUI_Component_Helper::sanitize_html_field($args['value'], $args); // Sanitize HTML.
634 634
 				} else {
635
-					$output .= sanitize_textarea_field( $args['value'] );
635
+					$output .= sanitize_textarea_field($args['value']);
636 636
 				}
637 637
 			}
638 638
 
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 
642 642
 		}
643 643
 
644
-		if ( ! empty( $args['label'] ) && $label_after ) {
644
+		if (!empty($args['label']) && $label_after) {
645 645
 			$label_args = array(
646 646
 				'title'      => $args['label'],
647 647
 				'for'        => $args['id'],
@@ -649,32 +649,32 @@  discard block
 block discarded – undo
649 649
 				'label_type' => $args['label_type'],
650 650
 				'label_col'  => $args['label_col']
651 651
 			);
652
-			$output .= self::label( $label_args );
652
+			$output .= self::label($label_args);
653 653
 		}
654 654
 
655 655
 		// help text
656
-		if ( ! empty( $args['help_text'] ) ) {
657
-			$output .= AUI_Component_Helper::help_text( $args['help_text'] );
656
+		if (!empty($args['help_text'])) {
657
+			$output .= AUI_Component_Helper::help_text($args['help_text']);
658 658
 		}
659 659
 
660 660
 		// maybe horizontal label
661
-		if ( $args['label_type'] == 'horizontal' ) {
661
+		if ($args['label_type'] == 'horizontal') {
662 662
 			$output .= '</div>';
663 663
 		}
664 664
 
665 665
 
666 666
 		// wrap
667
-		if ( ! $args['no_wrap'] ) {
667
+		if (!$args['no_wrap']) {
668 668
 			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
669 669
 			$wrap_class       = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
670
-			$wrap_class       = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
671
-			$output           = self::wrap( array(
670
+			$wrap_class       = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
671
+			$output           = self::wrap(array(
672 672
 				'content'         => $output,
673 673
 				'class'           => $wrap_class,
674 674
 				'element_require' => $args['element_require'],
675 675
 				'argument_id'     => $args['id'],
676 676
 				'wrap_attributes' => $args['wrap_attributes'],
677
-			) );
677
+			));
678 678
 		}
679 679
 
680 680
 
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 	 *
689 689
 	 * @return string The rendered component.
690 690
 	 */
691
-	public static function select( $args = array() ) {
691
+	public static function select($args = array()) {
692 692
 		$defaults = array(
693 693
 			'class'            => '',
694 694
 			'wrap_class'       => '',
@@ -725,11 +725,11 @@  discard block
 block discarded – undo
725 725
 		/**
726 726
 		 * Parse incoming $args into an array and merge it with $defaults
727 727
 		 */
728
-		$args   = wp_parse_args( $args, $defaults );
728
+		$args   = wp_parse_args($args, $defaults);
729 729
 		$output = '';
730 730
 
731 731
 		// for now lets hide floating labels
732
-		if ( $args['label_type'] == 'floating' ) {
732
+		if ($args['label_type'] == 'floating') {
733 733
 			$args['label_type'] = 'hidden';
734 734
 		}
735 735
 
@@ -740,31 +740,31 @@  discard block
 block discarded – undo
740 740
 		$label_after = $args['label_after'];
741 741
 
742 742
 		// floating labels need label after
743
-		if ( $args['label_type'] == 'floating' ) {
743
+		if ($args['label_type'] == 'floating') {
744 744
 			$label_after         = true;
745 745
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
746 746
 		}
747 747
 
748 748
 		// Maybe setup select2
749 749
 		$is_select2 = false;
750
-		if ( ! empty( $args['select2'] ) ) {
750
+		if (!empty($args['select2'])) {
751 751
 			$args['class'] .= ' aui-select2';
752 752
 			$is_select2 = true;
753
-		} elseif ( strpos( $args['class'], 'aui-select2' ) !== false ) {
753
+		} elseif (strpos($args['class'], 'aui-select2') !== false) {
754 754
 			$is_select2 = true;
755 755
 		}
756 756
 
757 757
 		// select2 tags
758
-		if ( ! empty( $args['select2'] ) && $args['select2'] === 'tags' ) { // triple equals needed here for some reason
758
+		if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason
759 759
 			$args['data-tags']             = 'true';
760 760
 			$args['data-token-separators'] = "[',']";
761 761
 			$args['multiple']              = true;
762 762
 		}
763 763
 
764 764
 		// select2 placeholder
765
-		if ( $is_select2 && isset( $args['placeholder'] ) && '' != $args['placeholder'] && empty( $args['data-placeholder'] ) ) {
766
-			$args['data-placeholder'] = esc_attr( $args['placeholder'] );
767
-			$args['data-allow-clear'] = isset( $args['data-allow-clear'] ) ? (bool) $args['data-allow-clear'] : true;
765
+		if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) {
766
+			$args['data-placeholder'] = esc_attr($args['placeholder']);
767
+			$args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
768 768
 		}
769 769
 
770 770
 
@@ -776,61 +776,61 @@  discard block
 block discarded – undo
776 776
 //		}
777 777
 
778 778
 		// Set hidden input to save empty value for multiselect.
779
-		if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
780
-			$output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>';
779
+		if (!empty($args['multiple']) && !empty($args['name'])) {
780
+			$output .= '<input type="hidden" ' . AUI_Component_Helper::name($args['name']) . ' value=""/>';
781 781
 		}
782 782
 
783 783
 		// open/type
784 784
 		$output .= '<select ';
785 785
 
786 786
 		// style
787
-		if ( $is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
787
+		if ($is_select2 && !($args['input_group_left'] || $args['input_group_right'])) {
788 788
 			$output .= " style='width:100%;' ";
789 789
 		}
790 790
 
791 791
 		// element require
792
-		if ( ! empty( $args['element_require'] ) ) {
793
-			$output .= AUI_Component_Helper::element_require( $args['element_require'] );
792
+		if (!empty($args['element_require'])) {
793
+			$output .= AUI_Component_Helper::element_require($args['element_require']);
794 794
 			$args['class'] .= " aui-conditional-field";
795 795
 		}
796 796
 
797 797
 		// class
798
-		$class = ! empty( $args['class'] ) ? $args['class'] : '';
799
-		$output .= AUI_Component_Helper::class_attr( 'custom-select ' . $class );
798
+		$class = !empty($args['class']) ? $args['class'] : '';
799
+		$output .= AUI_Component_Helper::class_attr('custom-select ' . $class);
800 800
 
801 801
 		// name
802
-		if ( ! empty( $args['name'] ) ) {
803
-			$output .= AUI_Component_Helper::name( $args['name'], $args['multiple'] );
802
+		if (!empty($args['name'])) {
803
+			$output .= AUI_Component_Helper::name($args['name'], $args['multiple']);
804 804
 		}
805 805
 
806 806
 		// id
807
-		if ( ! empty( $args['id'] ) ) {
808
-			$output .= AUI_Component_Helper::id( $args['id'] );
807
+		if (!empty($args['id'])) {
808
+			$output .= AUI_Component_Helper::id($args['id']);
809 809
 		}
810 810
 
811 811
 		// title
812
-		if ( ! empty( $args['title'] ) ) {
813
-			$output .= AUI_Component_Helper::title( $args['title'] );
812
+		if (!empty($args['title'])) {
813
+			$output .= AUI_Component_Helper::title($args['title']);
814 814
 		}
815 815
 
816 816
 		// data-attributes
817
-		$output .= AUI_Component_Helper::data_attributes( $args );
817
+		$output .= AUI_Component_Helper::data_attributes($args);
818 818
 
819 819
 		// aria-attributes
820
-		$output .= AUI_Component_Helper::aria_attributes( $args );
820
+		$output .= AUI_Component_Helper::aria_attributes($args);
821 821
 
822 822
 		// extra attributes
823
-		if ( ! empty( $args['extra_attributes'] ) ) {
824
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
823
+		if (!empty($args['extra_attributes'])) {
824
+			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
825 825
 		}
826 826
 
827 827
 		// required
828
-		if ( ! empty( $args['required'] ) ) {
828
+		if (!empty($args['required'])) {
829 829
 			$output .= ' required ';
830 830
 		}
831 831
 
832 832
 		// multiple
833
-		if ( ! empty( $args['multiple'] ) ) {
833
+		if (!empty($args['multiple'])) {
834 834
 			$output .= ' multiple ';
835 835
 		}
836 836
 
@@ -838,46 +838,46 @@  discard block
 block discarded – undo
838 838
 		$output .= ' >';
839 839
 
840 840
 		// placeholder
841
-		if ( isset( $args['placeholder'] ) && '' != $args['placeholder'] && ! $is_select2 ) {
842
-			$output .= '<option value="" disabled selected hidden>' . esc_attr( $args['placeholder'] ) . '</option>';
843
-		} elseif ( $is_select2 && ! empty( $args['placeholder'] ) ) {
841
+		if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) {
842
+			$output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>';
843
+		} elseif ($is_select2 && !empty($args['placeholder'])) {
844 844
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
845 845
 		}
846 846
 
847 847
 		// Options
848
-		if ( ! empty( $args['options'] ) ) {
848
+		if (!empty($args['options'])) {
849 849
 
850
-			if ( ! is_array( $args['options'] ) ) {
850
+			if (!is_array($args['options'])) {
851 851
 				$output .= $args['options']; // not the preferred way but an option
852 852
 			} else {
853
-				foreach ( $args['options'] as $val => $name ) {
853
+				foreach ($args['options'] as $val => $name) {
854 854
 					$selected = '';
855
-					if ( is_array( $name ) ) {
856
-						if ( isset( $name['optgroup'] ) && ( $name['optgroup'] == 'start' || $name['optgroup'] == 'end' ) ) {
857
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
855
+					if (is_array($name)) {
856
+						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
857
+							$option_label = isset($name['label']) ? $name['label'] : '';
858 858
 
859
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr( $option_label ) . '">' : '</optgroup>';
859
+							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
860 860
 						} else {
861
-							$option_label = isset( $name['label'] ) ? $name['label'] : '';
862
-							$option_value = isset( $name['value'] ) ? $name['value'] : '';
863
-							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes( $name['extra_attributes'] ) : '';
864
-							if ( ! empty( $args['multiple'] ) && ! empty( $args['value'] ) && is_array( $args['value'] ) ) {
865
-								$selected = in_array( $option_value, stripslashes_deep( $args['value'] ) ) ? "selected" : "";
866
-							} elseif ( ! empty( $args['value'] ) ) {
867
-								$selected = selected( $option_value, stripslashes_deep( $args['value'] ), false );
861
+							$option_label = isset($name['label']) ? $name['label'] : '';
862
+							$option_value = isset($name['value']) ? $name['value'] : '';
863
+							$extra_attributes = !empty($name['extra_attributes']) ? AUI_Component_Helper::extra_attributes($name['extra_attributes']) : '';
864
+							if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) {
865
+								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
866
+							} elseif (!empty($args['value'])) {
867
+								$selected = selected($option_value, stripslashes_deep($args['value']), false);
868 868
 							}
869 869
 
870
-							$output .= '<option value="' . esc_attr( $option_value ) . '" ' . $selected . ' '.$extra_attributes .'>' . $option_label . '</option>';
870
+							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . ' ' . $extra_attributes . '>' . $option_label . '</option>';
871 871
 						}
872 872
 					} else {
873
-						if ( ! empty( $args['value'] ) ) {
874
-							if ( is_array( $args['value'] ) ) {
875
-								$selected = in_array( $val, $args['value'] ) ? 'selected="selected"' : '';
876
-							} elseif ( ! empty( $args['value'] ) ) {
877
-								$selected = selected( $args['value'], $val, false );
873
+						if (!empty($args['value'])) {
874
+							if (is_array($args['value'])) {
875
+								$selected = in_array($val, $args['value']) ? 'selected="selected"' : '';
876
+							} elseif (!empty($args['value'])) {
877
+								$selected = selected($args['value'], $val, false);
878 878
 							}
879 879
 						}
880
-						$output .= '<option value="' . esc_attr( $val ) . '" ' . $selected . '>' . esc_attr( $name ) . '</option>';
880
+						$output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>';
881 881
 					}
882 882
 				}
883 883
 			}
@@ -890,8 +890,8 @@  discard block
 block discarded – undo
890 890
 		$label = '';
891 891
 		$help_text = '';
892 892
 		// label
893
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
894
-		} elseif ( ! empty( $args['label'] ) && ! $label_after ) {
893
+		if (!empty($args['label']) && is_array($args['label'])) {
894
+		} elseif (!empty($args['label']) && !$label_after) {
895 895
 			$label_args = array(
896 896
 				'title'      => $args['label'],
897 897
 				'for'        => $args['id'],
@@ -899,49 +899,49 @@  discard block
 block discarded – undo
899 899
 				'label_type' => $args['label_type'],
900 900
 				'label_col'  => $args['label_col']
901 901
 			);
902
-			$label = self::label( $label_args );
902
+			$label = self::label($label_args);
903 903
 		}
904 904
 
905 905
 		// help text
906
-		if ( ! empty( $args['help_text'] ) ) {
907
-			$help_text = AUI_Component_Helper::help_text( $args['help_text'] );
906
+		if (!empty($args['help_text'])) {
907
+			$help_text = AUI_Component_Helper::help_text($args['help_text']);
908 908
 		}
909 909
 
910 910
 		// input group wraps
911
-		if ( $args['input_group_left'] || $args['input_group_right'] ) {
912
-			$w100 = strpos( $args['class'], 'w-100' ) !== false ? ' w-100' : '';
913
-			if ( $args['input_group_left'] ) {
914
-				$output = self::wrap( array(
911
+		if ($args['input_group_left'] || $args['input_group_right']) {
912
+			$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
913
+			if ($args['input_group_left']) {
914
+				$output = self::wrap(array(
915 915
 					'content'                 => $output,
916 916
 					'class'                   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
917 917
 					'input_group_left'        => $args['input_group_left'],
918 918
 					'input_group_left_inside' => $args['input_group_left_inside']
919
-				) );
919
+				));
920 920
 			}
921
-			if ( $args['input_group_right'] ) {
922
-				$output = self::wrap( array(
921
+			if ($args['input_group_right']) {
922
+				$output = self::wrap(array(
923 923
 					'content'                  => $output,
924 924
 					'class'                    => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
925 925
 					'input_group_right'        => $args['input_group_right'],
926 926
 					'input_group_right_inside' => $args['input_group_right_inside']
927
-				) );
927
+				));
928 928
 			}
929 929
 
930 930
 		}
931 931
 
932
-		if ( ! $label_after ) {
932
+		if (!$label_after) {
933 933
 			$output .= $help_text;
934 934
 		}
935 935
 
936 936
 
937
-		if ( $args['label_type'] == 'horizontal' ) {
938
-			$output = self::wrap( array(
937
+		if ($args['label_type'] == 'horizontal') {
938
+			$output = self::wrap(array(
939 939
 				'content' => $output,
940
-				'class'   => AUI_Component_Helper::get_column_class( $args['label_col'], 'input' )
941
-			) );
940
+				'class'   => AUI_Component_Helper::get_column_class($args['label_col'], 'input')
941
+			));
942 942
 		}
943 943
 
944
-		if ( ! $label_after ) {
944
+		if (!$label_after) {
945 945
 			$output = $label . $output;
946 946
 		}
947 947
 
@@ -952,16 +952,16 @@  discard block
 block discarded – undo
952 952
 
953 953
 
954 954
 		// wrap
955
-		if ( ! $args['no_wrap'] ) {
955
+		if (!$args['no_wrap']) {
956 956
 			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
957
-			$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
958
-			$output     = self::wrap( array(
957
+			$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
958
+			$output     = self::wrap(array(
959 959
 				'content'         => $output,
960 960
 				'class'           => $wrap_class,
961 961
 				'element_require' => $args['element_require'],
962 962
 				'argument_id'     => $args['id'],
963 963
 				'wrap_attributes' => $args['wrap_attributes'],
964
-			) );
964
+			));
965 965
 		}
966 966
 
967 967
 
@@ -975,7 +975,7 @@  discard block
 block discarded – undo
975 975
 	 *
976 976
 	 * @return string The rendered component.
977 977
 	 */
978
-	public static function radio( $args = array() ) {
978
+	public static function radio($args = array()) {
979 979
 		$defaults = array(
980 980
 			'class'            => '',
981 981
 			'wrap_class'       => '',
@@ -1005,10 +1005,10 @@  discard block
 block discarded – undo
1005 1005
 		/**
1006 1006
 		 * Parse incoming $args into an array and merge it with $defaults
1007 1007
 		 */
1008
-		$args = wp_parse_args( $args, $defaults );
1008
+		$args = wp_parse_args($args, $defaults);
1009 1009
 
1010 1010
 		// for now lets use horizontal for floating
1011
-		if ( $args['label_type'] == 'floating' ) {
1011
+		if ($args['label_type'] == 'floating') {
1012 1012
 			$args['label_type'] = 'horizontal';
1013 1013
 		}
1014 1014
 
@@ -1023,47 +1023,47 @@  discard block
 block discarded – undo
1023 1023
 
1024 1024
 
1025 1025
 		// label before
1026
-		if ( ! empty( $args['label'] ) ) {
1027
-			$output .= self::label( $label_args, 'radio' );
1026
+		if (!empty($args['label'])) {
1027
+			$output .= self::label($label_args, 'radio');
1028 1028
 		}
1029 1029
 
1030 1030
 		// maybe horizontal label
1031
-		if ( $args['label_type'] == 'horizontal' ) {
1032
-			$input_col = AUI_Component_Helper::get_column_class( $args['label_col'], 'input' );
1031
+		if ($args['label_type'] == 'horizontal') {
1032
+			$input_col = AUI_Component_Helper::get_column_class($args['label_col'], 'input');
1033 1033
 			$output .= '<div class="' . $input_col . '">';
1034 1034
 		}
1035 1035
 
1036
-		if ( ! empty( $args['options'] ) ) {
1036
+		if (!empty($args['options'])) {
1037 1037
 			$count = 0;
1038
-			foreach ( $args['options'] as $value => $label ) {
1038
+			foreach ($args['options'] as $value => $label) {
1039 1039
 				$option_args            = $args;
1040 1040
 				$option_args['value']   = $value;
1041 1041
 				$option_args['label']   = $label;
1042 1042
 				$option_args['checked'] = $value == $args['value'] ? true : false;
1043
-				$output .= self::radio_option( $option_args, $count );
1044
-				$count ++;
1043
+				$output .= self::radio_option($option_args, $count);
1044
+				$count++;
1045 1045
 			}
1046 1046
 		}
1047 1047
 
1048 1048
 		// help text
1049
-		$help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
1049
+		$help_text = !empty($args['help_text']) ? AUI_Component_Helper::help_text($args['help_text']) : '';
1050 1050
 		$output .= $help_text;
1051 1051
 
1052 1052
 		// maybe horizontal label
1053
-		if ( $args['label_type'] == 'horizontal' ) {
1053
+		if ($args['label_type'] == 'horizontal') {
1054 1054
 			$output .= '</div>';
1055 1055
 		}
1056 1056
 
1057 1057
 		// wrap
1058 1058
 		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
1059
-		$wrap_class = ! empty( $args['wrap_class'] ) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1060
-		$output     = self::wrap( array(
1059
+		$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
1060
+		$output     = self::wrap(array(
1061 1061
 			'content'         => $output,
1062 1062
 			'class'           => $wrap_class,
1063 1063
 			'element_require' => $args['element_require'],
1064 1064
 			'argument_id'     => $args['id'],
1065 1065
 			'wrap_attributes' => $args['wrap_attributes'],
1066
-		) );
1066
+		));
1067 1067
 
1068 1068
 
1069 1069
 		return $output;
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 	 *
1077 1077
 	 * @return string The rendered component.
1078 1078
 	 */
1079
-	public static function radio_option( $args = array(), $count = '' ) {
1079
+	public static function radio_option($args = array(), $count = '') {
1080 1080
 		$defaults = array(
1081 1081
 			'class'            => '',
1082 1082
 			'id'               => '',
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 		/**
1095 1095
 		 * Parse incoming $args into an array and merge it with $defaults
1096 1096
 		 */
1097
-		$args = wp_parse_args( $args, $defaults );
1097
+		$args = wp_parse_args($args, $defaults);
1098 1098
 
1099 1099
 		$output = '';
1100 1100
 
@@ -1105,43 +1105,43 @@  discard block
 block discarded – undo
1105 1105
 		$output .= ' class="form-check-input" ';
1106 1106
 
1107 1107
 		// name
1108
-		if ( ! empty( $args['name'] ) ) {
1109
-			$output .= AUI_Component_Helper::name( $args['name'] );
1108
+		if (!empty($args['name'])) {
1109
+			$output .= AUI_Component_Helper::name($args['name']);
1110 1110
 		}
1111 1111
 
1112 1112
 		// id
1113
-		if ( ! empty( $args['id'] ) ) {
1114
-			$output .= AUI_Component_Helper::id( $args['id'] . $count );
1113
+		if (!empty($args['id'])) {
1114
+			$output .= AUI_Component_Helper::id($args['id'] . $count);
1115 1115
 		}
1116 1116
 
1117 1117
 		// title
1118
-		if ( ! empty( $args['title'] ) ) {
1119
-			$output .= AUI_Component_Helper::title( $args['title'] );
1118
+		if (!empty($args['title'])) {
1119
+			$output .= AUI_Component_Helper::title($args['title']);
1120 1120
 		}
1121 1121
 
1122 1122
 		// value
1123
-		if ( isset( $args['value'] ) ) {
1124
-			$output .= AUI_Component_Helper::value( $args['value'] );
1123
+		if (isset($args['value'])) {
1124
+			$output .= AUI_Component_Helper::value($args['value']);
1125 1125
 		}
1126 1126
 
1127 1127
 		// checked, for radio and checkboxes
1128
-		if ( $args['checked'] ) {
1128
+		if ($args['checked']) {
1129 1129
 			$output .= ' checked ';
1130 1130
 		}
1131 1131
 
1132 1132
 		// data-attributes
1133
-		$output .= AUI_Component_Helper::data_attributes( $args );
1133
+		$output .= AUI_Component_Helper::data_attributes($args);
1134 1134
 
1135 1135
 		// aria-attributes
1136
-		$output .= AUI_Component_Helper::aria_attributes( $args );
1136
+		$output .= AUI_Component_Helper::aria_attributes($args);
1137 1137
 
1138 1138
 		// extra attributes
1139
-		if ( ! empty( $args['extra_attributes'] ) ) {
1140
-			$output .= AUI_Component_Helper::extra_attributes( $args['extra_attributes'] );
1139
+		if (!empty($args['extra_attributes'])) {
1140
+			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
1141 1141
 		}
1142 1142
 
1143 1143
 		// required
1144
-		if ( ! empty( $args['required'] ) ) {
1144
+		if (!empty($args['required'])) {
1145 1145
 			$output .= ' required ';
1146 1146
 		}
1147 1147
 
@@ -1149,38 +1149,38 @@  discard block
 block discarded – undo
1149 1149
 		$output .= ' >';
1150 1150
 
1151 1151
 		// label
1152
-		if ( ! empty( $args['label'] ) && is_array( $args['label'] ) ) {
1153
-		} elseif ( ! empty( $args['label'] ) ) {
1154
-			$output .= self::label( array(
1152
+		if (!empty($args['label']) && is_array($args['label'])) {
1153
+		} elseif (!empty($args['label'])) {
1154
+			$output .= self::label(array(
1155 1155
 				'title' => $args['label'],
1156 1156
 				'for'   => $args['id'] . $count,
1157 1157
 				'class' => 'form-check-label'
1158
-			), 'radio' );
1158
+			), 'radio');
1159 1159
 		}
1160 1160
 
1161 1161
 		// wrap
1162
-		if ( ! $args['no_wrap'] ) {
1162
+		if (!$args['no_wrap']) {
1163 1163
 			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1164 1164
 
1165 1165
 			// Unique wrap class
1166 1166
 			$uniq_class = 'fwrap';
1167
-			if ( ! empty( $args['name'] ) ) {
1167
+			if (!empty($args['name'])) {
1168 1168
 				$uniq_class .= '-' . $args['name'];
1169
-			} else if ( ! empty( $args['id'] ) ) {
1169
+			} else if (!empty($args['id'])) {
1170 1170
 				$uniq_class .= '-' . $args['id'];
1171 1171
 			}
1172 1172
 
1173
-			if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1173
+			if (isset($args['value']) || $args['value'] !== "") {
1174 1174
 				$uniq_class .= '-' . $args['value'];
1175 1175
 			} else {
1176 1176
 				$uniq_class .= '-' . $count;
1177 1177
 			}
1178
-			$wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1178
+			$wrap_class .= ' ' . sanitize_html_class($uniq_class);
1179 1179
 
1180
-			$output = self::wrap( array(
1180
+			$output = self::wrap(array(
1181 1181
 				'content' => $output,
1182 1182
 				'class'   => $wrap_class
1183
-			) );
1183
+			));
1184 1184
 		}
1185 1185
 
1186 1186
 		return $output;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -209,7 +209,7 @@
 block discarded – undo
209 209
 						$help_text = '';
210 210
 						//$label_args['class'] .= ' d-inline ';
211 211
 						$args['wrap_class'] .= ' align-items-center ';
212
-					}else{
212
+					} else{
213 213
 
214 214
 					}
215 215
 
Please login to merge, or discard this patch.
includes/class-getpaid-invoice-notification-emails.php 2 patches
Indentation   +451 added lines, -451 removed lines patch added patch discarded remove patch
@@ -12,492 +12,492 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Invoice_Notification_Emails {
14 14
 
15
-	/**
16
-	 * The array of invoice email actions.
17
-	 *
18
-	 * @param array
19
-	 */
20
-	public $invoice_actions;
21
-
22
-	/**
23
-	 * Class constructor
24
-	 *
25
-	 */
26
-	public function __construct() {
27
-
28
-		$this->invoice_actions = apply_filters(
29
-			'getpaid_notification_email_invoice_triggers',
30
-			array(
31
-				'getpaid_new_invoice'                   => array( 'new_invoice', 'user_invoice' ),
32
-				'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
33
-				'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
34
-				'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
35
-				'getpaid_invoice_status_wpi-processing' => 'processing_invoice',
36
-				'getpaid_invoice_status_publish'        => 'completed_invoice',
37
-				'getpaid_invoice_status_wpi-renewal'    => 'completed_invoice',
38
-				'getpaid_invoice_status_wpi-refunded'   => 'refunded_invoice',
39
-				'getpaid_new_customer_note'             => 'user_note',
40
-				'getpaid_daily_maintenance'             => 'overdue',
41
-			)
42
-		);
43
-
44
-		$this->init_hooks();
45
-
46
-	}
47
-
48
-	/**
49
-	 * Registers email hooks.
50
-	 */
51
-	public function init_hooks() {
52
-
53
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
54
-		add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
55
-
56
-		foreach ( $this->invoice_actions as $hook => $email_type ) {
57
-			$this->init_email_type_hook( $hook, $email_type );
58
-		}
59
-	}
60
-
61
-	/**
62
-	 * Registers an email hook for an invoice action.
63
-	 * 
64
-	 * @param string $hook
65
-	 * @param string|array $email_type
66
-	 */
67
-	public function init_email_type_hook( $hook, $email_type ) {
68
-
69
-		$email_type = wpinv_parse_list( $email_type );
70
-
71
-		foreach ( $email_type as $type ) {
72
-
73
-			$email = new GetPaid_Notification_Email( $type );
74
-
75
-			// Abort if it is not active.
76
-			if ( ! $email->is_active() ) {
77
-				continue;
78
-			}
79
-
80
-			if ( method_exists( $this, $type ) ) {
81
-				add_action( $hook, array( $this, $type ), 100, 2 );
82
-				continue;
83
-			}
84
-
85
-			do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook );
86
-		}
87
-
88
-	}
89
-
90
-	/**
91
-	 * Filters invoice merge tags.
92
-	 *
93
-	 * @param array $merge_tags
94
-	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
95
-	 */
96
-	public function invoice_merge_tags( $merge_tags, $object ) {
97
-
98
-		if ( is_a( $object, 'WPInv_Invoice' ) ) {
99
-			return array_merge(
100
-				$merge_tags,
101
-				$this->get_invoice_merge_tags( $object )
102
-			);
103
-		}
104
-
105
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
106
-			return array_merge(
107
-				$merge_tags,
108
-				$this->get_invoice_merge_tags( $object->get_parent_payment() )
109
-			);
110
-		}
111
-
112
-		return $merge_tags;
113
-
114
-	}
115
-
116
-	/**
117
-	 * Generates invoice merge tags.
118
-	 *
119
-	 * @param WPInv_Invoice $invoice
120
-	 * @return array
121
-	 */
122
-	public function get_invoice_merge_tags( $invoice ) {
123
-
124
-		// Abort if it does not exist.
125
-		if ( ! $invoice->get_id() ) {
126
-			return array();
127
-		}
128
-
129
-		$merge_tags = array(
130
-			'{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
131
-			'{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
132
-			'{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
133
-			'{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
134
-			'{email}'               => sanitize_email( $invoice->get_email() ),
135
-			'{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
136
-			'{invoice_currency}'    => sanitize_text_field( $invoice->get_currency() ),
137
-			'{invoice_total}'       => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ),
138
-			'{invoice_link}'        => esc_url( $invoice->get_view_url() ),
139
-			'{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
140
-			'{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
141
-			'{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
142
-			'{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
143
-			'{invoice_quote}'       => sanitize_text_field( strtolower( $invoice->get_label() ) ),
144
-			'{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_label() ) ),
145
-			'{invoice_description}' => wp_kses_post( $invoice->get_description() ),
146
-			'{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
147
-			'{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
148
-		);
149
-
150
-		$payment_form_data = $invoice->get_meta( 'payment_form_data', true );
151
-
152
-		if ( is_array( $payment_form_data ) ) {
153
-
154
-			foreach ( $payment_form_data as $label => $value ) {
155
-
156
-				$label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) );
157
-				$value = is_array( $value ) ? implode( ', ', $value ) : $value;
158
-
159
-				if ( is_scalar ( $value ) ) {
160
-					$merge_tags[ "{{$label}}" ] = wp_kses_post( $value );
161
-				}
162
-
163
-			}
164
-
165
-		}
166
-
167
-		return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice );
168
-	}
169
-
170
-	/**
171
-	 * Helper function to send an email.
172
-	 *
173
-	 * @param WPInv_Invoice $invoice
174
-	 * @param GetPaid_Notification_Email $email
175
-	 * @param string $type
176
-	 * @param string|array $recipients
177
-	 * @param array $extra_args Extra template args.
178
-	 */
179
-	public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
180
-
181
-		do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
182
-
183
-		$skip = $invoice->is_free() && wpinv_get_option( 'skip_email_free_invoice' );
184
-		if ( apply_filters( 'getpaid_skip_invoice_email', $skip, $type, $invoice ) ) {
185
-			return;
186
-		}
187
-
188
-		$mailer     = new GetPaid_Notification_Email_Sender();
189
-		$merge_tags = $email->get_merge_tags();
190
-
191
-		$result = $mailer->send(
192
-			apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
193
-			$email->add_merge_tags( $email->get_subject(), $merge_tags ),
194
-			$email->get_content( $merge_tags, $extra_args ),
195
-			$email->get_attachments()
196
-		);
197
-
198
-		// Maybe send a copy to the admin.
199
-		if ( $email->include_admin_bcc() ) {
200
-			$mailer->send(
201
-				wpinv_get_admin_email(),
202
-				$email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
203
-				$email->get_content( $merge_tags ),
204
-				$email->get_attachments()
205
-			);
206
-		}
207
-
208
-		if ( $result ) {
209
-			$invoice->add_system_note(
210
-				sprintf(
211
-					__( 'Successfully sent %s notification email to %s.', 'invoicing' ),
212
-					sanitize_key( $type ),
213
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
214
-				)
215
-			);
216
-		} else {
217
-			$invoice->add_system_note(
218
-				sprintf(
219
-					__( 'Failed sending %s notification email to %s.', 'invoicing' ),
220
-					sanitize_key( $type ),
221
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
222
-				)
223
-			);	
224
-		}
225
-
226
-		do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
227
-
228
-		return $result;
229
-	}
230
-
231
-	/**
232
-	 * Also send emails to any cc users.
233
-	 *
234
-	 * @param array $recipients
235
-	 * @param GetPaid_Notification_Email $email
236
-	 */
237
-	public function filter_email_recipients( $recipients, $email ) {
238
-
239
-		if ( ! $email->is_admin_email() ) {
240
-			$cc   = $email->object->get_email_cc();
241
-			$cc_2 = get_user_meta( $email->object->get_user_id(), '_wpinv_email_cc', true );
242
-
243
-			if ( ! empty( $cc ) ) {
244
-				$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
245
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
246
-			}
247
-
248
-			if ( ! empty( $cc_2 ) ) {
249
-				$cc_2 = array_map( 'sanitize_email', wpinv_parse_list( $cc_2 ) );
250
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc_2 ) ) );
251
-			}
252
-
253
-		}
254
-
255
-		return $recipients;
256
-
257
-	}
258
-
259
-	/**
260
-	 * Sends a new invoice notification.
261
-	 *
262
-	 * @param WPInv_Invoice $invoice
263
-	 */
264
-	public function new_invoice( $invoice ) {
265
-
266
-		// Only send this email for invoices created via the admin page.
267
-		if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
268
-			return;
269
-		}
270
-
271
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
272
-		$recipient = wpinv_get_admin_email();
273
-
274
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
275
-
276
-	}
277
-
278
-	/**
279
-	 * Sends a cancelled invoice notification.
280
-	 *
281
-	 * @param WPInv_Invoice $invoice
282
-	 */
283
-	public function cancelled_invoice( $invoice ) {
284
-
285
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
286
-		$recipient = wpinv_get_admin_email();
287
-
288
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
289
-
290
-	}
291
-
292
-	/**
293
-	 * Sends a failed invoice notification.
294
-	 *
295
-	 * @param WPInv_Invoice $invoice
296
-	 */
297
-	public function failed_invoice( $invoice ) {
298
-
299
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
300
-		$recipient = wpinv_get_admin_email();
301
-
302
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
303
-
304
-	}
305
-
306
-	/**
307
-	 * Sends a notification whenever an invoice is put on hold.
308
-	 *
309
-	 * @param WPInv_Invoice $invoice
310
-	 */
311
-	public function onhold_invoice( $invoice ) {
312
-
313
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
314
-		$recipient = $invoice->get_email();
15
+    /**
16
+     * The array of invoice email actions.
17
+     *
18
+     * @param array
19
+     */
20
+    public $invoice_actions;
21
+
22
+    /**
23
+     * Class constructor
24
+     *
25
+     */
26
+    public function __construct() {
27
+
28
+        $this->invoice_actions = apply_filters(
29
+            'getpaid_notification_email_invoice_triggers',
30
+            array(
31
+                'getpaid_new_invoice'                   => array( 'new_invoice', 'user_invoice' ),
32
+                'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
33
+                'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
34
+                'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
35
+                'getpaid_invoice_status_wpi-processing' => 'processing_invoice',
36
+                'getpaid_invoice_status_publish'        => 'completed_invoice',
37
+                'getpaid_invoice_status_wpi-renewal'    => 'completed_invoice',
38
+                'getpaid_invoice_status_wpi-refunded'   => 'refunded_invoice',
39
+                'getpaid_new_customer_note'             => 'user_note',
40
+                'getpaid_daily_maintenance'             => 'overdue',
41
+            )
42
+        );
43
+
44
+        $this->init_hooks();
45
+
46
+    }
47
+
48
+    /**
49
+     * Registers email hooks.
50
+     */
51
+    public function init_hooks() {
52
+
53
+        add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
54
+        add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
55
+
56
+        foreach ( $this->invoice_actions as $hook => $email_type ) {
57
+            $this->init_email_type_hook( $hook, $email_type );
58
+        }
59
+    }
60
+
61
+    /**
62
+     * Registers an email hook for an invoice action.
63
+     * 
64
+     * @param string $hook
65
+     * @param string|array $email_type
66
+     */
67
+    public function init_email_type_hook( $hook, $email_type ) {
68
+
69
+        $email_type = wpinv_parse_list( $email_type );
70
+
71
+        foreach ( $email_type as $type ) {
72
+
73
+            $email = new GetPaid_Notification_Email( $type );
74
+
75
+            // Abort if it is not active.
76
+            if ( ! $email->is_active() ) {
77
+                continue;
78
+            }
79
+
80
+            if ( method_exists( $this, $type ) ) {
81
+                add_action( $hook, array( $this, $type ), 100, 2 );
82
+                continue;
83
+            }
84
+
85
+            do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook );
86
+        }
87
+
88
+    }
89
+
90
+    /**
91
+     * Filters invoice merge tags.
92
+     *
93
+     * @param array $merge_tags
94
+     * @param mixed|WPInv_Invoice|WPInv_Subscription $object
95
+     */
96
+    public function invoice_merge_tags( $merge_tags, $object ) {
97
+
98
+        if ( is_a( $object, 'WPInv_Invoice' ) ) {
99
+            return array_merge(
100
+                $merge_tags,
101
+                $this->get_invoice_merge_tags( $object )
102
+            );
103
+        }
104
+
105
+        if ( is_a( $object, 'WPInv_Subscription' ) ) {
106
+            return array_merge(
107
+                $merge_tags,
108
+                $this->get_invoice_merge_tags( $object->get_parent_payment() )
109
+            );
110
+        }
111
+
112
+        return $merge_tags;
113
+
114
+    }
115
+
116
+    /**
117
+     * Generates invoice merge tags.
118
+     *
119
+     * @param WPInv_Invoice $invoice
120
+     * @return array
121
+     */
122
+    public function get_invoice_merge_tags( $invoice ) {
123
+
124
+        // Abort if it does not exist.
125
+        if ( ! $invoice->get_id() ) {
126
+            return array();
127
+        }
128
+
129
+        $merge_tags = array(
130
+            '{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
131
+            '{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
132
+            '{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
133
+            '{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
134
+            '{email}'               => sanitize_email( $invoice->get_email() ),
135
+            '{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
136
+            '{invoice_currency}'    => sanitize_text_field( $invoice->get_currency() ),
137
+            '{invoice_total}'       => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ),
138
+            '{invoice_link}'        => esc_url( $invoice->get_view_url() ),
139
+            '{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
140
+            '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
141
+            '{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
142
+            '{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
143
+            '{invoice_quote}'       => sanitize_text_field( strtolower( $invoice->get_label() ) ),
144
+            '{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_label() ) ),
145
+            '{invoice_description}' => wp_kses_post( $invoice->get_description() ),
146
+            '{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
147
+            '{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
148
+        );
149
+
150
+        $payment_form_data = $invoice->get_meta( 'payment_form_data', true );
151
+
152
+        if ( is_array( $payment_form_data ) ) {
153
+
154
+            foreach ( $payment_form_data as $label => $value ) {
155
+
156
+                $label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) );
157
+                $value = is_array( $value ) ? implode( ', ', $value ) : $value;
158
+
159
+                if ( is_scalar ( $value ) ) {
160
+                    $merge_tags[ "{{$label}}" ] = wp_kses_post( $value );
161
+                }
162
+
163
+            }
164
+
165
+        }
166
+
167
+        return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice );
168
+    }
169
+
170
+    /**
171
+     * Helper function to send an email.
172
+     *
173
+     * @param WPInv_Invoice $invoice
174
+     * @param GetPaid_Notification_Email $email
175
+     * @param string $type
176
+     * @param string|array $recipients
177
+     * @param array $extra_args Extra template args.
178
+     */
179
+    public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
180
+
181
+        do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
182
+
183
+        $skip = $invoice->is_free() && wpinv_get_option( 'skip_email_free_invoice' );
184
+        if ( apply_filters( 'getpaid_skip_invoice_email', $skip, $type, $invoice ) ) {
185
+            return;
186
+        }
187
+
188
+        $mailer     = new GetPaid_Notification_Email_Sender();
189
+        $merge_tags = $email->get_merge_tags();
190
+
191
+        $result = $mailer->send(
192
+            apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
193
+            $email->add_merge_tags( $email->get_subject(), $merge_tags ),
194
+            $email->get_content( $merge_tags, $extra_args ),
195
+            $email->get_attachments()
196
+        );
197
+
198
+        // Maybe send a copy to the admin.
199
+        if ( $email->include_admin_bcc() ) {
200
+            $mailer->send(
201
+                wpinv_get_admin_email(),
202
+                $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
203
+                $email->get_content( $merge_tags ),
204
+                $email->get_attachments()
205
+            );
206
+        }
207
+
208
+        if ( $result ) {
209
+            $invoice->add_system_note(
210
+                sprintf(
211
+                    __( 'Successfully sent %s notification email to %s.', 'invoicing' ),
212
+                    sanitize_key( $type ),
213
+                    $email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
214
+                )
215
+            );
216
+        } else {
217
+            $invoice->add_system_note(
218
+                sprintf(
219
+                    __( 'Failed sending %s notification email to %s.', 'invoicing' ),
220
+                    sanitize_key( $type ),
221
+                    $email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
222
+                )
223
+            );	
224
+        }
225
+
226
+        do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
227
+
228
+        return $result;
229
+    }
230
+
231
+    /**
232
+     * Also send emails to any cc users.
233
+     *
234
+     * @param array $recipients
235
+     * @param GetPaid_Notification_Email $email
236
+     */
237
+    public function filter_email_recipients( $recipients, $email ) {
238
+
239
+        if ( ! $email->is_admin_email() ) {
240
+            $cc   = $email->object->get_email_cc();
241
+            $cc_2 = get_user_meta( $email->object->get_user_id(), '_wpinv_email_cc', true );
242
+
243
+            if ( ! empty( $cc ) ) {
244
+                $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
245
+                $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
246
+            }
247
+
248
+            if ( ! empty( $cc_2 ) ) {
249
+                $cc_2 = array_map( 'sanitize_email', wpinv_parse_list( $cc_2 ) );
250
+                $recipients = array_filter( array_unique( array_merge( $recipients, $cc_2 ) ) );
251
+            }
252
+
253
+        }
254
+
255
+        return $recipients;
256
+
257
+    }
258
+
259
+    /**
260
+     * Sends a new invoice notification.
261
+     *
262
+     * @param WPInv_Invoice $invoice
263
+     */
264
+    public function new_invoice( $invoice ) {
265
+
266
+        // Only send this email for invoices created via the admin page.
267
+        if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
268
+            return;
269
+        }
270
+
271
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
272
+        $recipient = wpinv_get_admin_email();
273
+
274
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
275
+
276
+    }
277
+
278
+    /**
279
+     * Sends a cancelled invoice notification.
280
+     *
281
+     * @param WPInv_Invoice $invoice
282
+     */
283
+    public function cancelled_invoice( $invoice ) {
284
+
285
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
286
+        $recipient = wpinv_get_admin_email();
287
+
288
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
289
+
290
+    }
291
+
292
+    /**
293
+     * Sends a failed invoice notification.
294
+     *
295
+     * @param WPInv_Invoice $invoice
296
+     */
297
+    public function failed_invoice( $invoice ) {
298
+
299
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
300
+        $recipient = wpinv_get_admin_email();
301
+
302
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
303
+
304
+    }
305
+
306
+    /**
307
+     * Sends a notification whenever an invoice is put on hold.
308
+     *
309
+     * @param WPInv_Invoice $invoice
310
+     */
311
+    public function onhold_invoice( $invoice ) {
312
+
313
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
314
+        $recipient = $invoice->get_email();
315 315
 
316
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
316
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
317 317
 
318
-	}
318
+    }
319 319
 
320
-	/**
321
-	 * Sends a notification whenever an invoice is marked as processing payment.
322
-	 *
323
-	 * @param WPInv_Invoice $invoice
324
-	 */
325
-	public function processing_invoice( $invoice ) {
320
+    /**
321
+     * Sends a notification whenever an invoice is marked as processing payment.
322
+     *
323
+     * @param WPInv_Invoice $invoice
324
+     */
325
+    public function processing_invoice( $invoice ) {
326 326
 
327
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
328
-		$recipient = $invoice->get_email();
327
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
328
+        $recipient = $invoice->get_email();
329 329
 
330
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
331
-
332
-	}
333
-
334
-	/**
335
-	 * Sends a notification whenever an invoice is paid.
336
-	 *
337
-	 * @param WPInv_Invoice $invoice
338
-	 */
339
-	public function completed_invoice( $invoice ) {
330
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
331
+
332
+    }
333
+
334
+    /**
335
+     * Sends a notification whenever an invoice is paid.
336
+     *
337
+     * @param WPInv_Invoice $invoice
338
+     */
339
+    public function completed_invoice( $invoice ) {
340 340
 
341
-		// (Maybe) abort if it is a renewal invoice.
342
-		if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
343
-			return;
344
-		}
341
+        // (Maybe) abort if it is a renewal invoice.
342
+        if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
343
+            return;
344
+        }
345 345
 
346
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
347
-		$recipient = $invoice->get_email();
346
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
347
+        $recipient = $invoice->get_email();
348 348
 
349
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
349
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
350 350
 
351
-	}
351
+    }
352 352
 
353
-	/**
354
-	 * Sends a notification whenever an invoice is refunded.
355
-	 *
356
-	 * @param WPInv_Invoice $invoice
357
-	 */
358
-	public function refunded_invoice( $invoice ) {
353
+    /**
354
+     * Sends a notification whenever an invoice is refunded.
355
+     *
356
+     * @param WPInv_Invoice $invoice
357
+     */
358
+    public function refunded_invoice( $invoice ) {
359 359
 
360
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
361
-		$recipient = $invoice->get_email();
360
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
361
+        $recipient = $invoice->get_email();
362 362
 
363
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
363
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
364 364
 
365
-	}
365
+    }
366 366
 
367
-	/**
368
-	 * Notifies a user about new invoices
369
-	 *
370
-	 * @param WPInv_Invoice $invoice
371
-	 * @param bool $force
372
-	 */
373
-	public function user_invoice( $invoice, $force = false ) {
367
+    /**
368
+     * Notifies a user about new invoices
369
+     *
370
+     * @param WPInv_Invoice $invoice
371
+     * @param bool $force
372
+     */
373
+    public function user_invoice( $invoice, $force = false ) {
374 374
 
375
-		if ( ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) {
376
-			return;
377
-		}
378
-
379
-		// Only send this email for invoices created via the admin page.
380
-		if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) {
381
-			return;
382
-		}
375
+        if ( ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) {
376
+            return;
377
+        }
378
+
379
+        // Only send this email for invoices created via the admin page.
380
+        if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) {
381
+            return;
382
+        }
383 383
 
384
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
385
-		$recipient = $invoice->get_email();
384
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
385
+        $recipient = $invoice->get_email();
386 386
 
387
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
387
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
388 388
 
389
-	}
390
-
391
-	/**
392
-	 * Checks if an invoice is a payment form invoice.
393
-	 *
394
-	 * @param int $invoice
395
-	 * @return bool
396
-	 */
397
-	public function is_payment_form_invoice( $invoice ) {
398
-		$is_payment_form_invoice = empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) );
399
-		return apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice );
400
-	}
389
+    }
390
+
391
+    /**
392
+     * Checks if an invoice is a payment form invoice.
393
+     *
394
+     * @param int $invoice
395
+     * @return bool
396
+     */
397
+    public function is_payment_form_invoice( $invoice ) {
398
+        $is_payment_form_invoice = empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) );
399
+        return apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice );
400
+    }
401 401
 
402
-	/**
403
-	 * Notifies admin about new invoice notes
404
-	 *
405
-	 * @param WPInv_Invoice $invoice
406
-	 * @param string $note
407
-	 */
408
-	public function user_note( $invoice, $note ) {
409
-
410
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
411
-		$recipient = $invoice->get_email();
402
+    /**
403
+     * Notifies admin about new invoice notes
404
+     *
405
+     * @param WPInv_Invoice $invoice
406
+     * @param string $note
407
+     */
408
+    public function user_note( $invoice, $note ) {
409
+
410
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
411
+        $recipient = $invoice->get_email();
412 412
 
413
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
414
-
415
-	}
416
-
417
-	/**
418
-	 * (Force) Sends overdue notices.
419
-	 *
420
-	 * @param WPInv_Invoice $invoice
421
-	 */
422
-	public function force_send_overdue_notice( $invoice ) {
423
-		$email = new GetPaid_Notification_Email( 'overdue', $invoice );
424
-		return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
425
-	}
426
-
427
-	/**
428
-	 * Sends overdue notices.
429
-	 *
430
-	 * @TODO: Create an invoices query class.
431
-	 */
432
-	public function overdue() {
433
-		global $wpdb;
434
-
435
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
436
-
437
-		// Fetch reminder days.
438
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
439
-
440
-		// Abort if non is set.
441
-		if ( empty( $reminder_days ) ) {
442
-			return;
443
-		}
444
-
445
-		// Retrieve date query.
446
-		$date_query = $this->get_date_query( $reminder_days );
447
-
448
-		// Invoices table.
449
-		$table = $wpdb->prefix . 'getpaid_invoices';
450
-
451
-		// Fetch invoices.
452
-		$invoices  = $wpdb->get_col(
453
-			"SELECT posts.ID FROM $wpdb->posts as posts
413
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
414
+
415
+    }
416
+
417
+    /**
418
+     * (Force) Sends overdue notices.
419
+     *
420
+     * @param WPInv_Invoice $invoice
421
+     */
422
+    public function force_send_overdue_notice( $invoice ) {
423
+        $email = new GetPaid_Notification_Email( 'overdue', $invoice );
424
+        return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
425
+    }
426
+
427
+    /**
428
+     * Sends overdue notices.
429
+     *
430
+     * @TODO: Create an invoices query class.
431
+     */
432
+    public function overdue() {
433
+        global $wpdb;
434
+
435
+        $email = new GetPaid_Notification_Email( __FUNCTION__ );
436
+
437
+        // Fetch reminder days.
438
+        $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
439
+
440
+        // Abort if non is set.
441
+        if ( empty( $reminder_days ) ) {
442
+            return;
443
+        }
444
+
445
+        // Retrieve date query.
446
+        $date_query = $this->get_date_query( $reminder_days );
447
+
448
+        // Invoices table.
449
+        $table = $wpdb->prefix . 'getpaid_invoices';
450
+
451
+        // Fetch invoices.
452
+        $invoices  = $wpdb->get_col(
453
+            "SELECT posts.ID FROM $wpdb->posts as posts
454 454
 			LEFT JOIN $table as invoices ON invoices.post_id = posts.ID
455 455
 			WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query");
456 456
 
457
-		foreach ( $invoices as $invoice ) {
457
+        foreach ( $invoices as $invoice ) {
458 458
 
459
-			// Only send this email for invoices created via the admin page.
460
-			if ( ! $this->is_payment_form_invoice( $invoice ) ) {
461
-				$invoice       = new WPInv_Invoice( $invoice );
462
-				$email->object = $invoice;
459
+            // Only send this email for invoices created via the admin page.
460
+            if ( ! $this->is_payment_form_invoice( $invoice ) ) {
461
+                $invoice       = new WPInv_Invoice( $invoice );
462
+                $email->object = $invoice;
463 463
 
464
-				if ( $invoice->needs_payment() ) {
465
-					$this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
466
-				}
464
+                if ( $invoice->needs_payment() ) {
465
+                    $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
466
+                }
467 467
 
468
-			}
468
+            }
469 469
 
470
-		}
470
+        }
471 471
 
472
-	}
472
+    }
473 473
 
474
-	/**
475
-	 * Calculates the date query for an invoices query
476
-	 *
477
-	 * @param array $reminder_days
478
-	 * @return string
479
-	 */
480
-	public function get_date_query( $reminder_days ) {
474
+    /**
475
+     * Calculates the date query for an invoices query
476
+     *
477
+     * @param array $reminder_days
478
+     * @return string
479
+     */
480
+    public function get_date_query( $reminder_days ) {
481 481
 
482
-		$date_query = array(
483
-			'relation'  => 'OR'
484
-		);
482
+        $date_query = array(
483
+            'relation'  => 'OR'
484
+        );
485 485
 
486
-		foreach ( $reminder_days as $days ) {
487
-			$date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
486
+        foreach ( $reminder_days as $days ) {
487
+            $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
488 488
 
489
-			$date_query[] = array(
490
-				'year'  => $date['year'],
491
-				'month' => $date['month'],
492
-				'day'   => $date['day'],
493
-			);
489
+            $date_query[] = array(
490
+                'year'  => $date['year'],
491
+                'month' => $date['month'],
492
+                'day'   => $date['day'],
493
+            );
494 494
 
495
-		}
495
+        }
496 496
 
497
-		$date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
497
+        $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
498 498
 
499
-		return $date_query->get_sql();
499
+        return $date_query->get_sql();
500 500
 
501
-	}
501
+    }
502 502
 
503 503
 }
Please login to merge, or discard this patch.
Spacing   +125 added lines, -125 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
  * This class handles invoice notificaiton emails.
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		$this->invoice_actions = apply_filters(
29 29
 			'getpaid_notification_email_invoice_triggers',
30 30
 			array(
31
-				'getpaid_new_invoice'                   => array( 'new_invoice', 'user_invoice' ),
31
+				'getpaid_new_invoice'                   => array('new_invoice', 'user_invoice'),
32 32
 				'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
33 33
 				'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
34 34
 				'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	public function init_hooks() {
52 52
 
53
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
54
-		add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
53
+		add_filter('getpaid_get_email_merge_tags', array($this, 'invoice_merge_tags'), 10, 2);
54
+		add_filter('getpaid_invoice_email_recipients', array($this, 'filter_email_recipients'), 10, 2);
55 55
 
56
-		foreach ( $this->invoice_actions as $hook => $email_type ) {
57
-			$this->init_email_type_hook( $hook, $email_type );
56
+		foreach ($this->invoice_actions as $hook => $email_type) {
57
+			$this->init_email_type_hook($hook, $email_type);
58 58
 		}
59 59
 	}
60 60
 
@@ -64,25 +64,25 @@  discard block
 block discarded – undo
64 64
 	 * @param string $hook
65 65
 	 * @param string|array $email_type
66 66
 	 */
67
-	public function init_email_type_hook( $hook, $email_type ) {
67
+	public function init_email_type_hook($hook, $email_type) {
68 68
 
69
-		$email_type = wpinv_parse_list( $email_type );
69
+		$email_type = wpinv_parse_list($email_type);
70 70
 
71
-		foreach ( $email_type as $type ) {
71
+		foreach ($email_type as $type) {
72 72
 
73
-			$email = new GetPaid_Notification_Email( $type );
73
+			$email = new GetPaid_Notification_Email($type);
74 74
 
75 75
 			// Abort if it is not active.
76
-			if ( ! $email->is_active() ) {
76
+			if (!$email->is_active()) {
77 77
 				continue;
78 78
 			}
79 79
 
80
-			if ( method_exists( $this, $type ) ) {
81
-				add_action( $hook, array( $this, $type ), 100, 2 );
80
+			if (method_exists($this, $type)) {
81
+				add_action($hook, array($this, $type), 100, 2);
82 82
 				continue;
83 83
 			}
84 84
 
85
-			do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook );
85
+			do_action('getpaid_invoice_init_email_type_hook', $type, $hook);
86 86
 		}
87 87
 
88 88
 	}
@@ -93,19 +93,19 @@  discard block
 block discarded – undo
93 93
 	 * @param array $merge_tags
94 94
 	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
95 95
 	 */
96
-	public function invoice_merge_tags( $merge_tags, $object ) {
96
+	public function invoice_merge_tags($merge_tags, $object) {
97 97
 
98
-		if ( is_a( $object, 'WPInv_Invoice' ) ) {
98
+		if (is_a($object, 'WPInv_Invoice')) {
99 99
 			return array_merge(
100 100
 				$merge_tags,
101
-				$this->get_invoice_merge_tags( $object )
101
+				$this->get_invoice_merge_tags($object)
102 102
 			);
103 103
 		}
104 104
 
105
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
105
+		if (is_a($object, 'WPInv_Subscription')) {
106 106
 			return array_merge(
107 107
 				$merge_tags,
108
-				$this->get_invoice_merge_tags( $object->get_parent_payment() )
108
+				$this->get_invoice_merge_tags($object->get_parent_payment())
109 109
 			);
110 110
 		}
111 111
 
@@ -119,52 +119,52 @@  discard block
 block discarded – undo
119 119
 	 * @param WPInv_Invoice $invoice
120 120
 	 * @return array
121 121
 	 */
122
-	public function get_invoice_merge_tags( $invoice ) {
122
+	public function get_invoice_merge_tags($invoice) {
123 123
 
124 124
 		// Abort if it does not exist.
125
-		if ( ! $invoice->get_id() ) {
125
+		if (!$invoice->get_id()) {
126 126
 			return array();
127 127
 		}
128 128
 
129 129
 		$merge_tags = array(
130
-			'{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
131
-			'{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
132
-			'{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
133
-			'{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
134
-			'{email}'               => sanitize_email( $invoice->get_email() ),
135
-			'{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
136
-			'{invoice_currency}'    => sanitize_text_field( $invoice->get_currency() ),
137
-			'{invoice_total}'       => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ),
138
-			'{invoice_link}'        => esc_url( $invoice->get_view_url() ),
139
-			'{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
140
-			'{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
141
-			'{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
142
-			'{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
143
-			'{invoice_quote}'       => sanitize_text_field( strtolower( $invoice->get_label() ) ),
144
-			'{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_label() ) ),
145
-			'{invoice_description}' => wp_kses_post( $invoice->get_description() ),
146
-			'{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
147
-			'{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
130
+			'{name}'                => sanitize_text_field($invoice->get_user_full_name()),
131
+			'{full_name}'           => sanitize_text_field($invoice->get_user_full_name()),
132
+			'{first_name}'          => sanitize_text_field($invoice->get_first_name()),
133
+			'{last_name}'           => sanitize_text_field($invoice->get_last_name()),
134
+			'{email}'               => sanitize_email($invoice->get_email()),
135
+			'{invoice_number}'      => sanitize_text_field($invoice->get_number()),
136
+			'{invoice_currency}'    => sanitize_text_field($invoice->get_currency()),
137
+			'{invoice_total}'       => sanitize_text_field(wpinv_price($invoice->get_total(), $invoice->get_currency())),
138
+			'{invoice_link}'        => esc_url($invoice->get_view_url()),
139
+			'{invoice_pay_link}'    => esc_url($invoice->get_checkout_payment_url()),
140
+			'{invoice_receipt_link}'=> esc_url($invoice->get_receipt_url()),
141
+			'{invoice_date}'        => getpaid_format_date_value($invoice->get_date_created()),
142
+			'{invoice_due_date}'    => getpaid_format_date_value($invoice->get_due_date(), __('on receipt', 'invoicing')),
143
+			'{invoice_quote}'       => sanitize_text_field(strtolower($invoice->get_label())),
144
+			'{invoice_label}'       => sanitize_text_field(ucfirst($invoice->get_label())),
145
+			'{invoice_description}' => wp_kses_post($invoice->get_description()),
146
+			'{subscription_name}'   => wp_kses_post($invoice->get_subscription_name()),
147
+			'{is_was}'              => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'),
148 148
 		);
149 149
 
150
-		$payment_form_data = $invoice->get_meta( 'payment_form_data', true );
150
+		$payment_form_data = $invoice->get_meta('payment_form_data', true);
151 151
 
152
-		if ( is_array( $payment_form_data ) ) {
152
+		if (is_array($payment_form_data)) {
153 153
 
154
-			foreach ( $payment_form_data as $label => $value ) {
154
+			foreach ($payment_form_data as $label => $value) {
155 155
 
156
-				$label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) );
157
-				$value = is_array( $value ) ? implode( ', ', $value ) : $value;
156
+				$label = preg_replace('/[^a-z0-9]+/', '_', strtolower($label));
157
+				$value = is_array($value) ? implode(', ', $value) : $value;
158 158
 
159
-				if ( is_scalar ( $value ) ) {
160
-					$merge_tags[ "{{$label}}" ] = wp_kses_post( $value );
159
+				if (is_scalar($value)) {
160
+					$merge_tags["{{$label}}"] = wp_kses_post($value);
161 161
 				}
162 162
 
163 163
 			}
164 164
 
165 165
 		}
166 166
 
167
-		return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice );
167
+		return apply_filters('getpaid_invoice_email_merge_tags', $merge_tags, $invoice);
168 168
 	}
169 169
 
170 170
 	/**
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
 	 * @param string|array $recipients
177 177
 	 * @param array $extra_args Extra template args.
178 178
 	 */
179
-	public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
179
+	public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) {
180 180
 
181
-		do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
181
+		do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email);
182 182
 
183
-		$skip = $invoice->is_free() && wpinv_get_option( 'skip_email_free_invoice' );
184
-		if ( apply_filters( 'getpaid_skip_invoice_email', $skip, $type, $invoice ) ) {
183
+		$skip = $invoice->is_free() && wpinv_get_option('skip_email_free_invoice');
184
+		if (apply_filters('getpaid_skip_invoice_email', $skip, $type, $invoice)) {
185 185
 			return;
186 186
 		}
187 187
 
@@ -189,41 +189,41 @@  discard block
 block discarded – undo
189 189
 		$merge_tags = $email->get_merge_tags();
190 190
 
191 191
 		$result = $mailer->send(
192
-			apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
193
-			$email->add_merge_tags( $email->get_subject(), $merge_tags ),
194
-			$email->get_content( $merge_tags, $extra_args ),
192
+			apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email),
193
+			$email->add_merge_tags($email->get_subject(), $merge_tags),
194
+			$email->get_content($merge_tags, $extra_args),
195 195
 			$email->get_attachments()
196 196
 		);
197 197
 
198 198
 		// Maybe send a copy to the admin.
199
-		if ( $email->include_admin_bcc() ) {
199
+		if ($email->include_admin_bcc()) {
200 200
 			$mailer->send(
201 201
 				wpinv_get_admin_email(),
202
-				$email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
203
-				$email->get_content( $merge_tags ),
202
+				$email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags),
203
+				$email->get_content($merge_tags),
204 204
 				$email->get_attachments()
205 205
 			);
206 206
 		}
207 207
 
208
-		if ( $result ) {
208
+		if ($result) {
209 209
 			$invoice->add_system_note(
210 210
 				sprintf(
211
-					__( 'Successfully sent %s notification email to %s.', 'invoicing' ),
212
-					sanitize_key( $type ),
213
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
211
+					__('Successfully sent %s notification email to %s.', 'invoicing'),
212
+					sanitize_key($type),
213
+					$email->is_admin_email() ? __('admin') : __('the customer')
214 214
 				)
215 215
 			);
216 216
 		} else {
217 217
 			$invoice->add_system_note(
218 218
 				sprintf(
219
-					__( 'Failed sending %s notification email to %s.', 'invoicing' ),
220
-					sanitize_key( $type ),
221
-					$email->is_admin_email() ? __( 'admin' ) : __( 'the customer' )
219
+					__('Failed sending %s notification email to %s.', 'invoicing'),
220
+					sanitize_key($type),
221
+					$email->is_admin_email() ? __('admin') : __('the customer')
222 222
 				)
223 223
 			);	
224 224
 		}
225 225
 
226
-		do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
226
+		do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email);
227 227
 
228 228
 		return $result;
229 229
 	}
@@ -234,20 +234,20 @@  discard block
 block discarded – undo
234 234
 	 * @param array $recipients
235 235
 	 * @param GetPaid_Notification_Email $email
236 236
 	 */
237
-	public function filter_email_recipients( $recipients, $email ) {
237
+	public function filter_email_recipients($recipients, $email) {
238 238
 
239
-		if ( ! $email->is_admin_email() ) {
239
+		if (!$email->is_admin_email()) {
240 240
 			$cc   = $email->object->get_email_cc();
241
-			$cc_2 = get_user_meta( $email->object->get_user_id(), '_wpinv_email_cc', true );
241
+			$cc_2 = get_user_meta($email->object->get_user_id(), '_wpinv_email_cc', true);
242 242
 
243
-			if ( ! empty( $cc ) ) {
244
-				$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
245
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
243
+			if (!empty($cc)) {
244
+				$cc = array_map('sanitize_email', wpinv_parse_list($cc));
245
+				$recipients = array_filter(array_unique(array_merge($recipients, $cc)));
246 246
 			}
247 247
 
248
-			if ( ! empty( $cc_2 ) ) {
249
-				$cc_2 = array_map( 'sanitize_email', wpinv_parse_list( $cc_2 ) );
250
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc_2 ) ) );
248
+			if (!empty($cc_2)) {
249
+				$cc_2 = array_map('sanitize_email', wpinv_parse_list($cc_2));
250
+				$recipients = array_filter(array_unique(array_merge($recipients, $cc_2)));
251 251
 			}
252 252
 
253 253
 		}
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @param WPInv_Invoice $invoice
263 263
 	 */
264
-	public function new_invoice( $invoice ) {
264
+	public function new_invoice($invoice) {
265 265
 
266 266
 		// Only send this email for invoices created via the admin page.
267
-		if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || $this->is_payment_form_invoice( $invoice->get_id() ) ) {
267
+		if (!$invoice->is_type('invoice') || $invoice->is_paid() || $this->is_payment_form_invoice($invoice->get_id())) {
268 268
 			return;
269 269
 		}
270 270
 
271
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
271
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
272 272
 		$recipient = wpinv_get_admin_email();
273 273
 
274
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
274
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
275 275
 
276 276
 	}
277 277
 
@@ -280,12 +280,12 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @param WPInv_Invoice $invoice
282 282
 	 */
283
-	public function cancelled_invoice( $invoice ) {
283
+	public function cancelled_invoice($invoice) {
284 284
 
285
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
285
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
286 286
 		$recipient = wpinv_get_admin_email();
287 287
 
288
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
288
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
289 289
 
290 290
 	}
291 291
 
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @param WPInv_Invoice $invoice
296 296
 	 */
297
-	public function failed_invoice( $invoice ) {
297
+	public function failed_invoice($invoice) {
298 298
 
299
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
299
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
300 300
 		$recipient = wpinv_get_admin_email();
301 301
 
302
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
302
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
303 303
 
304 304
 	}
305 305
 
@@ -308,12 +308,12 @@  discard block
 block discarded – undo
308 308
 	 *
309 309
 	 * @param WPInv_Invoice $invoice
310 310
 	 */
311
-	public function onhold_invoice( $invoice ) {
311
+	public function onhold_invoice($invoice) {
312 312
 
313
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
313
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
314 314
 		$recipient = $invoice->get_email();
315 315
 
316
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
316
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
317 317
 
318 318
 	}
319 319
 
@@ -322,12 +322,12 @@  discard block
 block discarded – undo
322 322
 	 *
323 323
 	 * @param WPInv_Invoice $invoice
324 324
 	 */
325
-	public function processing_invoice( $invoice ) {
325
+	public function processing_invoice($invoice) {
326 326
 
327
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
327
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
328 328
 		$recipient = $invoice->get_email();
329 329
 
330
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
330
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
331 331
 
332 332
 	}
333 333
 
@@ -336,17 +336,17 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * @param WPInv_Invoice $invoice
338 338
 	 */
339
-	public function completed_invoice( $invoice ) {
339
+	public function completed_invoice($invoice) {
340 340
 
341 341
 		// (Maybe) abort if it is a renewal invoice.
342
-		if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
342
+		if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) {
343 343
 			return;
344 344
 		}
345 345
 
346
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
346
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
347 347
 		$recipient = $invoice->get_email();
348 348
 
349
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
349
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
350 350
 
351 351
 	}
352 352
 
@@ -355,12 +355,12 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
 	 * @param WPInv_Invoice $invoice
357 357
 	 */
358
-	public function refunded_invoice( $invoice ) {
358
+	public function refunded_invoice($invoice) {
359 359
 
360
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
360
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
361 361
 		$recipient = $invoice->get_email();
362 362
 
363
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
363
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
364 364
 
365 365
 	}
366 366
 
@@ -370,21 +370,21 @@  discard block
 block discarded – undo
370 370
 	 * @param WPInv_Invoice $invoice
371 371
 	 * @param bool $force
372 372
 	 */
373
-	public function user_invoice( $invoice, $force = false ) {
373
+	public function user_invoice($invoice, $force = false) {
374 374
 
375
-		if ( ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) {
375
+		if (!empty($GLOBALS['wpinv_skip_invoice_notification'])) {
376 376
 			return;
377 377
 		}
378 378
 
379 379
 		// Only send this email for invoices created via the admin page.
380
-		if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_paid() || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) {
380
+		if (!$invoice->is_type('invoice') || $invoice->is_paid() || (empty($force) && $this->is_payment_form_invoice($invoice->get_id()))) {
381 381
 			return;
382 382
 		}
383 383
 
384
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
384
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
385 385
 		$recipient = $invoice->get_email();
386 386
 
387
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
387
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
388 388
 
389 389
 	}
390 390
 
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 	 * @param int $invoice
395 395
 	 * @return bool
396 396
 	 */
397
-	public function is_payment_form_invoice( $invoice ) {
398
-		$is_payment_form_invoice = empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) );
399
-		return apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice );
397
+	public function is_payment_form_invoice($invoice) {
398
+		$is_payment_form_invoice = empty($_GET['getpaid-admin-action']) && ('payment_form' == get_post_meta($invoice, 'wpinv_created_via', true) || 'geodirectory' == get_post_meta($invoice, 'wpinv_created_via', true));
399
+		return apply_filters('getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice);
400 400
 	}
401 401
 
402 402
 	/**
@@ -405,12 +405,12 @@  discard block
 block discarded – undo
405 405
 	 * @param WPInv_Invoice $invoice
406 406
 	 * @param string $note
407 407
 	 */
408
-	public function user_note( $invoice, $note ) {
408
+	public function user_note($invoice, $note) {
409 409
 
410
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
410
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
411 411
 		$recipient = $invoice->get_email();
412 412
 
413
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
413
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note));
414 414
 
415 415
 	}
416 416
 
@@ -419,9 +419,9 @@  discard block
 block discarded – undo
419 419
 	 *
420 420
 	 * @param WPInv_Invoice $invoice
421 421
 	 */
422
-	public function force_send_overdue_notice( $invoice ) {
423
-		$email = new GetPaid_Notification_Email( 'overdue', $invoice );
424
-		return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
422
+	public function force_send_overdue_notice($invoice) {
423
+		$email = new GetPaid_Notification_Email('overdue', $invoice);
424
+		return $this->send_email($invoice, $email, 'overdue', $invoice->get_email());
425 425
 	}
426 426
 
427 427
 	/**
@@ -432,37 +432,37 @@  discard block
 block discarded – undo
432 432
 	public function overdue() {
433 433
 		global $wpdb;
434 434
 
435
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
435
+		$email = new GetPaid_Notification_Email(__FUNCTION__);
436 436
 
437 437
 		// Fetch reminder days.
438
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
438
+		$reminder_days = array_unique(wp_parse_id_list($email->get_option('days')));
439 439
 
440 440
 		// Abort if non is set.
441
-		if ( empty( $reminder_days ) ) {
441
+		if (empty($reminder_days)) {
442 442
 			return;
443 443
 		}
444 444
 
445 445
 		// Retrieve date query.
446
-		$date_query = $this->get_date_query( $reminder_days );
446
+		$date_query = $this->get_date_query($reminder_days);
447 447
 
448 448
 		// Invoices table.
449 449
 		$table = $wpdb->prefix . 'getpaid_invoices';
450 450
 
451 451
 		// Fetch invoices.
452
-		$invoices  = $wpdb->get_col(
452
+		$invoices = $wpdb->get_col(
453 453
 			"SELECT posts.ID FROM $wpdb->posts as posts
454 454
 			LEFT JOIN $table as invoices ON invoices.post_id = posts.ID
455 455
 			WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query");
456 456
 
457
-		foreach ( $invoices as $invoice ) {
457
+		foreach ($invoices as $invoice) {
458 458
 
459 459
 			// Only send this email for invoices created via the admin page.
460
-			if ( ! $this->is_payment_form_invoice( $invoice ) ) {
461
-				$invoice       = new WPInv_Invoice( $invoice );
460
+			if (!$this->is_payment_form_invoice($invoice)) {
461
+				$invoice       = new WPInv_Invoice($invoice);
462 462
 				$email->object = $invoice;
463 463
 
464
-				if ( $invoice->needs_payment() ) {
465
-					$this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
464
+				if ($invoice->needs_payment()) {
465
+					$this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email());
466 466
 				}
467 467
 
468 468
 			}
@@ -477,14 +477,14 @@  discard block
 block discarded – undo
477 477
 	 * @param array $reminder_days
478 478
 	 * @return string
479 479
 	 */
480
-	public function get_date_query( $reminder_days ) {
480
+	public function get_date_query($reminder_days) {
481 481
 
482 482
 		$date_query = array(
483 483
 			'relation'  => 'OR'
484 484
 		);
485 485
 
486
-		foreach ( $reminder_days as $days ) {
487
-			$date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
486
+		foreach ($reminder_days as $days) {
487
+			$date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp'))));
488 488
 
489 489
 			$date_query[] = array(
490 490
 				'year'  => $date['year'],
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 
495 495
 		}
496 496
 
497
-		$date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
497
+		$date_query = new WP_Date_Query($date_query, 'invoices.due_date');
498 498
 
499 499
 		return $date_query->get_sql();
500 500
 
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
  * Bail if we are not in WP.
8 8
  */
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit;
10
+    exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16 16
 add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
18
-	$this_version = "0.1.64";
19
-	if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
22
-	}
17
+    global $ayecode_ui_version,$ayecode_ui_file_key;
18
+    $this_version = "0.1.64";
19
+    if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
+        $ayecode_ui_version = $this_version ;
21
+        $ayecode_ui_file_key = wp_hash( __FILE__ );
22
+    }
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28 28
 add_action('after_setup_theme', function () {
29
-	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
-	}
29
+    global $ayecode_ui_file_key;
30
+    if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
+        include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
+        include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
+    }
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39 39
 if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
42
-			return false;
43
-		}
44
-		return AUI::instance();
45
-	}
40
+    function aui(){
41
+        if(!class_exists("AUI",false)){
42
+            return false;
43
+        }
44
+        return AUI::instance();
45
+    }
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
 /**
7 7
  * Bail if we are not in WP.
8 8
  */
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16
-add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
16
+add_action('after_setup_theme', function() {
17
+	global $ayecode_ui_version, $ayecode_ui_file_key;
18 18
 	$this_version = "0.1.64";
19
-	if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
19
+	if (empty($ayecode_ui_version) || version_compare($this_version, $ayecode_ui_version, '>')) {
20
+		$ayecode_ui_version = $this_version;
21
+		$ayecode_ui_file_key = wp_hash(__FILE__);
22 22
 	}
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28
-add_action('after_setup_theme', function () {
28
+add_action('after_setup_theme', function() {
29 29
 	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
30
+	if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) {
31
+		include_once(dirname(__FILE__) . '/includes/class-aui.php');
32
+		include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php');
33 33
 	}
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39
-if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
39
+if (!function_exists('aui')) {
40
+	function aui() {
41
+		if (!class_exists("AUI", false)) {
42 42
 			return false;
43 43
 		}
44 44
 		return AUI::instance();
Please login to merge, or discard this patch.
vendor/composer/InstalledVersions.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 class InstalledVersions
13 13
 {
14 14
 private static $installed = array (
15
-  'root' => 
16
-  array (
15
+    'root' => 
16
+    array (
17 17
     'pretty_version' => 'dev-master',
18 18
     'version' => 'dev-master',
19 19
     'aliases' => 
@@ -21,96 +21,96 @@  discard block
 block discarded – undo
21 21
     ),
22 22
     'reference' => '9f729ee78be545f474a617e1a4abb041d6f6eb4a',
23 23
     'name' => 'ayecode/invoicing',
24
-  ),
25
-  'versions' => 
26
-  array (
24
+    ),
25
+    'versions' => 
26
+    array (
27 27
     'ayecode/ayecode-connect-helper' => 
28 28
     array (
29
-      'pretty_version' => '1.0.3',
30
-      'version' => '1.0.3.0',
31
-      'aliases' => 
32
-      array (
33
-      ),
34
-      'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
29
+        'pretty_version' => '1.0.3',
30
+        'version' => '1.0.3.0',
31
+        'aliases' => 
32
+        array (
33
+        ),
34
+        'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
35 35
     ),
36 36
     'ayecode/invoicing' => 
37 37
     array (
38
-      'pretty_version' => 'dev-master',
39
-      'version' => 'dev-master',
40
-      'aliases' => 
41
-      array (
42
-      ),
43
-      'reference' => '9f729ee78be545f474a617e1a4abb041d6f6eb4a',
38
+        'pretty_version' => 'dev-master',
39
+        'version' => 'dev-master',
40
+        'aliases' => 
41
+        array (
42
+        ),
43
+        'reference' => '9f729ee78be545f474a617e1a4abb041d6f6eb4a',
44 44
     ),
45 45
     'ayecode/wp-ayecode-ui' => 
46 46
     array (
47
-      'pretty_version' => '0.1.64',
48
-      'version' => '0.1.64.0',
49
-      'aliases' => 
50
-      array (
51
-      ),
52
-      'reference' => 'e47b13915328f4253e470646ebd1dcd2b753e09f',
47
+        'pretty_version' => '0.1.64',
48
+        'version' => '0.1.64.0',
49
+        'aliases' => 
50
+        array (
51
+        ),
52
+        'reference' => 'e47b13915328f4253e470646ebd1dcd2b753e09f',
53 53
     ),
54 54
     'ayecode/wp-deactivation-survey' => 
55 55
     array (
56
-      'pretty_version' => '1.0.4',
57
-      'version' => '1.0.4.0',
58
-      'aliases' => 
59
-      array (
60
-      ),
61
-      'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398',
56
+        'pretty_version' => '1.0.4',
57
+        'version' => '1.0.4.0',
58
+        'aliases' => 
59
+        array (
60
+        ),
61
+        'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398',
62 62
     ),
63 63
     'ayecode/wp-font-awesome-settings' => 
64 64
     array (
65
-      'pretty_version' => '1.0.13',
66
-      'version' => '1.0.13.0',
67
-      'aliases' => 
68
-      array (
69
-      ),
70
-      'reference' => 'a7a11ee4290674ec214d1fe694139af275350402',
65
+        'pretty_version' => '1.0.13',
66
+        'version' => '1.0.13.0',
67
+        'aliases' => 
68
+        array (
69
+        ),
70
+        'reference' => 'a7a11ee4290674ec214d1fe694139af275350402',
71 71
     ),
72 72
     'ayecode/wp-super-duper' => 
73 73
     array (
74
-      'pretty_version' => '1.0.29',
75
-      'version' => '1.0.29.0',
76
-      'aliases' => 
77
-      array (
78
-      ),
79
-      'reference' => '18f3da558aec750cfeaa582f72619fbf8867677a',
74
+        'pretty_version' => '1.0.29',
75
+        'version' => '1.0.29.0',
76
+        'aliases' => 
77
+        array (
78
+        ),
79
+        'reference' => '18f3da558aec750cfeaa582f72619fbf8867677a',
80 80
     ),
81 81
     'composer/installers' => 
82 82
     array (
83
-      'pretty_version' => 'v1.12.0',
84
-      'version' => '1.12.0.0',
85
-      'aliases' => 
86
-      array (
87
-      ),
88
-      'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
83
+        'pretty_version' => 'v1.12.0',
84
+        'version' => '1.12.0.0',
85
+        'aliases' => 
86
+        array (
87
+        ),
88
+        'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
89 89
     ),
90 90
     'maxmind-db/reader' => 
91 91
     array (
92
-      'pretty_version' => 'v1.6.0',
93
-      'version' => '1.6.0.0',
94
-      'aliases' => 
95
-      array (
96
-      ),
97
-      'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
92
+        'pretty_version' => 'v1.6.0',
93
+        'version' => '1.6.0.0',
94
+        'aliases' => 
95
+        array (
96
+        ),
97
+        'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
98 98
     ),
99 99
     'roundcube/plugin-installer' => 
100 100
     array (
101
-      'replaced' => 
102
-      array (
101
+        'replaced' => 
102
+        array (
103 103
         0 => '*',
104
-      ),
104
+        ),
105 105
     ),
106 106
     'shama/baton' => 
107 107
     array (
108
-      'replaced' => 
109
-      array (
108
+        'replaced' => 
109
+        array (
110 110
         0 => '*',
111
-      ),
111
+        ),
112
+    ),
112 113
     ),
113
-  ),
114 114
 );
115 115
 
116 116
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -11,102 +11,102 @@
 block discarded – undo
11 11
 
12 12
 class InstalledVersions
13 13
 {
14
-private static $installed = array (
14
+private static $installed = array(
15 15
   'root' => 
16
-  array (
16
+  array(
17 17
     'pretty_version' => 'dev-master',
18 18
     'version' => 'dev-master',
19 19
     'aliases' => 
20
-    array (
20
+    array(
21 21
     ),
22 22
     'reference' => '9f729ee78be545f474a617e1a4abb041d6f6eb4a',
23 23
     'name' => 'ayecode/invoicing',
24 24
   ),
25 25
   'versions' => 
26
-  array (
26
+  array(
27 27
     'ayecode/ayecode-connect-helper' => 
28
-    array (
28
+    array(
29 29
       'pretty_version' => '1.0.3',
30 30
       'version' => '1.0.3.0',
31 31
       'aliases' => 
32
-      array (
32
+      array(
33 33
       ),
34 34
       'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
35 35
     ),
36 36
     'ayecode/invoicing' => 
37
-    array (
37
+    array(
38 38
       'pretty_version' => 'dev-master',
39 39
       'version' => 'dev-master',
40 40
       'aliases' => 
41
-      array (
41
+      array(
42 42
       ),
43 43
       'reference' => '9f729ee78be545f474a617e1a4abb041d6f6eb4a',
44 44
     ),
45 45
     'ayecode/wp-ayecode-ui' => 
46
-    array (
46
+    array(
47 47
       'pretty_version' => '0.1.64',
48 48
       'version' => '0.1.64.0',
49 49
       'aliases' => 
50
-      array (
50
+      array(
51 51
       ),
52 52
       'reference' => 'e47b13915328f4253e470646ebd1dcd2b753e09f',
53 53
     ),
54 54
     'ayecode/wp-deactivation-survey' => 
55
-    array (
55
+    array(
56 56
       'pretty_version' => '1.0.4',
57 57
       'version' => '1.0.4.0',
58 58
       'aliases' => 
59
-      array (
59
+      array(
60 60
       ),
61 61
       'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398',
62 62
     ),
63 63
     'ayecode/wp-font-awesome-settings' => 
64
-    array (
64
+    array(
65 65
       'pretty_version' => '1.0.13',
66 66
       'version' => '1.0.13.0',
67 67
       'aliases' => 
68
-      array (
68
+      array(
69 69
       ),
70 70
       'reference' => 'a7a11ee4290674ec214d1fe694139af275350402',
71 71
     ),
72 72
     'ayecode/wp-super-duper' => 
73
-    array (
73
+    array(
74 74
       'pretty_version' => '1.0.29',
75 75
       'version' => '1.0.29.0',
76 76
       'aliases' => 
77
-      array (
77
+      array(
78 78
       ),
79 79
       'reference' => '18f3da558aec750cfeaa582f72619fbf8867677a',
80 80
     ),
81 81
     'composer/installers' => 
82
-    array (
82
+    array(
83 83
       'pretty_version' => 'v1.12.0',
84 84
       'version' => '1.12.0.0',
85 85
       'aliases' => 
86
-      array (
86
+      array(
87 87
       ),
88 88
       'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
89 89
     ),
90 90
     'maxmind-db/reader' => 
91
-    array (
91
+    array(
92 92
       'pretty_version' => 'v1.6.0',
93 93
       'version' => '1.6.0.0',
94 94
       'aliases' => 
95
-      array (
95
+      array(
96 96
       ),
97 97
       'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
98 98
     ),
99 99
     'roundcube/plugin-installer' => 
100
-    array (
100
+    array(
101 101
       'replaced' => 
102
-      array (
102
+      array(
103 103
         0 => '*',
104 104
       ),
105 105
     ),
106 106
     'shama/baton' => 
107
-    array (
107
+    array(
108 108
       'replaced' => 
109
-      array (
109
+      array(
110 110
         0 => '*',
111 111
       ),
112 112
     ),
Please login to merge, or discard this patch.
vendor/composer/installed.php 2 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php return array (
2
-  'root' => 
3
-  array (
2
+    'root' => 
3
+    array (
4 4
     'pretty_version' => 'dev-master',
5 5
     'version' => 'dev-master',
6 6
     'aliases' => 
@@ -8,94 +8,94 @@  discard block
 block discarded – undo
8 8
     ),
9 9
     'reference' => '9f729ee78be545f474a617e1a4abb041d6f6eb4a',
10 10
     'name' => 'ayecode/invoicing',
11
-  ),
12
-  'versions' => 
13
-  array (
11
+    ),
12
+    'versions' => 
13
+    array (
14 14
     'ayecode/ayecode-connect-helper' => 
15 15
     array (
16
-      'pretty_version' => '1.0.3',
17
-      'version' => '1.0.3.0',
18
-      'aliases' => 
19
-      array (
20
-      ),
21
-      'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
16
+        'pretty_version' => '1.0.3',
17
+        'version' => '1.0.3.0',
18
+        'aliases' => 
19
+        array (
20
+        ),
21
+        'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
22 22
     ),
23 23
     'ayecode/invoicing' => 
24 24
     array (
25
-      'pretty_version' => 'dev-master',
26
-      'version' => 'dev-master',
27
-      'aliases' => 
28
-      array (
29
-      ),
30
-      'reference' => '9f729ee78be545f474a617e1a4abb041d6f6eb4a',
25
+        'pretty_version' => 'dev-master',
26
+        'version' => 'dev-master',
27
+        'aliases' => 
28
+        array (
29
+        ),
30
+        'reference' => '9f729ee78be545f474a617e1a4abb041d6f6eb4a',
31 31
     ),
32 32
     'ayecode/wp-ayecode-ui' => 
33 33
     array (
34
-      'pretty_version' => '0.1.64',
35
-      'version' => '0.1.64.0',
36
-      'aliases' => 
37
-      array (
38
-      ),
39
-      'reference' => 'e47b13915328f4253e470646ebd1dcd2b753e09f',
34
+        'pretty_version' => '0.1.64',
35
+        'version' => '0.1.64.0',
36
+        'aliases' => 
37
+        array (
38
+        ),
39
+        'reference' => 'e47b13915328f4253e470646ebd1dcd2b753e09f',
40 40
     ),
41 41
     'ayecode/wp-deactivation-survey' => 
42 42
     array (
43
-      'pretty_version' => '1.0.4',
44
-      'version' => '1.0.4.0',
45
-      'aliases' => 
46
-      array (
47
-      ),
48
-      'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398',
43
+        'pretty_version' => '1.0.4',
44
+        'version' => '1.0.4.0',
45
+        'aliases' => 
46
+        array (
47
+        ),
48
+        'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398',
49 49
     ),
50 50
     'ayecode/wp-font-awesome-settings' => 
51 51
     array (
52
-      'pretty_version' => '1.0.13',
53
-      'version' => '1.0.13.0',
54
-      'aliases' => 
55
-      array (
56
-      ),
57
-      'reference' => 'a7a11ee4290674ec214d1fe694139af275350402',
52
+        'pretty_version' => '1.0.13',
53
+        'version' => '1.0.13.0',
54
+        'aliases' => 
55
+        array (
56
+        ),
57
+        'reference' => 'a7a11ee4290674ec214d1fe694139af275350402',
58 58
     ),
59 59
     'ayecode/wp-super-duper' => 
60 60
     array (
61
-      'pretty_version' => '1.0.29',
62
-      'version' => '1.0.29.0',
63
-      'aliases' => 
64
-      array (
65
-      ),
66
-      'reference' => '18f3da558aec750cfeaa582f72619fbf8867677a',
61
+        'pretty_version' => '1.0.29',
62
+        'version' => '1.0.29.0',
63
+        'aliases' => 
64
+        array (
65
+        ),
66
+        'reference' => '18f3da558aec750cfeaa582f72619fbf8867677a',
67 67
     ),
68 68
     'composer/installers' => 
69 69
     array (
70
-      'pretty_version' => 'v1.12.0',
71
-      'version' => '1.12.0.0',
72
-      'aliases' => 
73
-      array (
74
-      ),
75
-      'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
70
+        'pretty_version' => 'v1.12.0',
71
+        'version' => '1.12.0.0',
72
+        'aliases' => 
73
+        array (
74
+        ),
75
+        'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
76 76
     ),
77 77
     'maxmind-db/reader' => 
78 78
     array (
79
-      'pretty_version' => 'v1.6.0',
80
-      'version' => '1.6.0.0',
81
-      'aliases' => 
82
-      array (
83
-      ),
84
-      'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
79
+        'pretty_version' => 'v1.6.0',
80
+        'version' => '1.6.0.0',
81
+        'aliases' => 
82
+        array (
83
+        ),
84
+        'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
85 85
     ),
86 86
     'roundcube/plugin-installer' => 
87 87
     array (
88
-      'replaced' => 
89
-      array (
88
+        'replaced' => 
89
+        array (
90 90
         0 => '*',
91
-      ),
91
+        ),
92 92
     ),
93 93
     'shama/baton' => 
94 94
     array (
95
-      'replaced' => 
96
-      array (
95
+        'replaced' => 
96
+        array (
97 97
         0 => '*',
98
-      ),
98
+        ),
99
+    ),
99 100
     ),
100
-  ),
101 101
 );
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -1,99 +1,99 @@
 block discarded – undo
1
-<?php return array (
1
+<?php return array(
2 2
   'root' => 
3
-  array (
3
+  array(
4 4
     'pretty_version' => 'dev-master',
5 5
     'version' => 'dev-master',
6 6
     'aliases' => 
7
-    array (
7
+    array(
8 8
     ),
9 9
     'reference' => '9f729ee78be545f474a617e1a4abb041d6f6eb4a',
10 10
     'name' => 'ayecode/invoicing',
11 11
   ),
12 12
   'versions' => 
13
-  array (
13
+  array(
14 14
     'ayecode/ayecode-connect-helper' => 
15
-    array (
15
+    array(
16 16
       'pretty_version' => '1.0.3',
17 17
       'version' => '1.0.3.0',
18 18
       'aliases' => 
19
-      array (
19
+      array(
20 20
       ),
21 21
       'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4',
22 22
     ),
23 23
     'ayecode/invoicing' => 
24
-    array (
24
+    array(
25 25
       'pretty_version' => 'dev-master',
26 26
       'version' => 'dev-master',
27 27
       'aliases' => 
28
-      array (
28
+      array(
29 29
       ),
30 30
       'reference' => '9f729ee78be545f474a617e1a4abb041d6f6eb4a',
31 31
     ),
32 32
     'ayecode/wp-ayecode-ui' => 
33
-    array (
33
+    array(
34 34
       'pretty_version' => '0.1.64',
35 35
       'version' => '0.1.64.0',
36 36
       'aliases' => 
37
-      array (
37
+      array(
38 38
       ),
39 39
       'reference' => 'e47b13915328f4253e470646ebd1dcd2b753e09f',
40 40
     ),
41 41
     'ayecode/wp-deactivation-survey' => 
42
-    array (
42
+    array(
43 43
       'pretty_version' => '1.0.4',
44 44
       'version' => '1.0.4.0',
45 45
       'aliases' => 
46
-      array (
46
+      array(
47 47
       ),
48 48
       'reference' => 'd2777fed30acfc4da53b45bf3b4fec2fb27d8398',
49 49
     ),
50 50
     'ayecode/wp-font-awesome-settings' => 
51
-    array (
51
+    array(
52 52
       'pretty_version' => '1.0.13',
53 53
       'version' => '1.0.13.0',
54 54
       'aliases' => 
55
-      array (
55
+      array(
56 56
       ),
57 57
       'reference' => 'a7a11ee4290674ec214d1fe694139af275350402',
58 58
     ),
59 59
     'ayecode/wp-super-duper' => 
60
-    array (
60
+    array(
61 61
       'pretty_version' => '1.0.29',
62 62
       'version' => '1.0.29.0',
63 63
       'aliases' => 
64
-      array (
64
+      array(
65 65
       ),
66 66
       'reference' => '18f3da558aec750cfeaa582f72619fbf8867677a',
67 67
     ),
68 68
     'composer/installers' => 
69
-    array (
69
+    array(
70 70
       'pretty_version' => 'v1.12.0',
71 71
       'version' => '1.12.0.0',
72 72
       'aliases' => 
73
-      array (
73
+      array(
74 74
       ),
75 75
       'reference' => 'd20a64ed3c94748397ff5973488761b22f6d3f19',
76 76
     ),
77 77
     'maxmind-db/reader' => 
78
-    array (
78
+    array(
79 79
       'pretty_version' => 'v1.6.0',
80 80
       'version' => '1.6.0.0',
81 81
       'aliases' => 
82
-      array (
82
+      array(
83 83
       ),
84 84
       'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4',
85 85
     ),
86 86
     'roundcube/plugin-installer' => 
87
-    array (
87
+    array(
88 88
       'replaced' => 
89
-      array (
89
+      array(
90 90
         0 => '*',
91 91
       ),
92 92
     ),
93 93
     'shama/baton' => 
94
-    array (
94
+    array(
95 95
       'replaced' => 
96
-      array (
96
+      array(
97 97
         0 => '*',
98 98
       ),
99 99
     ),
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-details.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Item_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the item.
@@ -270,35 +270,35 @@  discard block
 block discarded – undo
270 270
     }
271 271
 
272 272
     /**
273
-	 * Save meta box data.
274
-	 *
275
-	 * @param int $post_id
276
-	 */
277
-	public static function save( $post_id ) {
273
+     * Save meta box data.
274
+     *
275
+     * @param int $post_id
276
+     */
277
+    public static function save( $post_id ) {
278 278
 
279 279
         // Prepare the item.
280 280
         $item = new WPInv_Item( $post_id );
281 281
 
282 282
         // Load new data.
283 283
         $item->set_props(
284
-			array(
285
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
-				'is_dynamic_pricing'   => ! empty( $_POST['wpinv_name_your_price'] ),
284
+            array(
285
+                'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
+                'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
+                'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
+                'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
+                'is_dynamic_pricing'   => ! empty( $_POST['wpinv_name_your_price'] ),
290 290
                 'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
291
-				'is_recurring'         => ! empty( $_POST['wpinv_is_recurring'] ),
292
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
298
-			)
291
+                'is_recurring'         => ! empty( $_POST['wpinv_is_recurring'] ),
292
+                'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
+                'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
+                'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
+                'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
+                'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
+                'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
298
+            )
299 299
         );
300 300
 
301
-		$item->save();
302
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
303
-	}
301
+        $item->save();
302
+        do_action( 'getpaid_item_metabox_save', $post_id, $item );
303
+    }
304 304
 }
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,27 +21,27 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32 32
         // Set the currency position.
33 33
         $position = wpinv_currency_position();
34 34
 
35
-        if ( $position == 'left_space' ) {
35
+        if ($position == 'left_space') {
36 36
             $position = 'left';
37 37
         }
38 38
 
39
-        if ( $position == 'right_space' ) {
39
+        if ($position == 'right_space') {
40 40
             $position = 'right';
41 41
         }
42 42
 
43 43
         ?>
44
-        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" />
44
+        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" />
45 45
         <style>
46 46
             #poststuff .input-group-text,
47 47
             #poststuff .form-control {
@@ -55,21 +55,21 @@  discard block
 block discarded – undo
55 55
         </style>
56 56
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
57 57
 
58
-            <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?>
58
+            <?php do_action('wpinv_item_details_metabox_before_price', $item); ?>
59 59
             <div class="form-group row">
60
-                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label>
60
+                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label>
61 61
                 <div class="col-sm-8">
62 62
                     <div class="row">
63 63
                         <div class="col-sm-4 getpaid-price-input">
64 64
                             <div class="input-group input-group-sm">
65
-                                <?php if( 'left' == $position ) : ?>
65
+                                <?php if ('left' == $position) : ?>
66 66
                                 <div class="input-group-prepend">
67 67
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
68 68
                                 </div>
69 69
                                 <?php endif; ?>
70
-                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
70
+                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
71 71
 
72
-                                <?php if( 'left' != $position ) : ?>
72
+                                <?php if ('left' != $position) : ?>
73 73
                                 <div class="input-group-append">
74 74
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
75 75
                                 </div>
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
                         </div>
80 80
                         <div class="col-sm-4 wpinv_show_if_recurring">
81 81
                             <?php
82
-                                _e( 'every' );
82
+                                _e('every');
83 83
                                 echo "&nbsp;";
84 84
                             ?>
85
-                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
85
+                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
86 86
                         </div>
87 87
                         <div class="col-sm-4 wpinv_show_if_recurring">
88 88
                             <?php
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
                                     array(
91 91
                                         'id'               => 'wpinv_recurring_period',
92 92
                                         'name'             => 'wpinv_recurring_period',
93
-                                        'label'            => __( 'Period', 'invoicing' ),
94
-                                        'placeholder'      => __( 'Select Period', 'invoicing' ),
95
-                                        'value'            => $item->get_recurring_period( 'edit' ),
93
+                                        'label'            => __('Period', 'invoicing'),
94
+                                        'placeholder'      => __('Select Period', 'invoicing'),
95
+                                        'value'            => $item->get_recurring_period('edit'),
96 96
                                         'select2'          => true,
97 97
                                         'data-allow-clear' => 'false',
98 98
                                         'options'     => array(
99
-                                            'D'  => __( 'day(s)', 'invoicing' ),
100
-                                            'W'  => __( 'week(s)', 'invoicing' ),
101
-                                            'M'  => __( 'month(s)', 'invoicing' ),
102
-                                            'Y'  => __( 'year(s)', 'invoicing' ),
99
+                                            'D'  => __('day(s)', 'invoicing'),
100
+                                            'W'  => __('week(s)', 'invoicing'),
101
+                                            'M'  => __('month(s)', 'invoicing'),
102
+                                            'Y'  => __('year(s)', 'invoicing'),
103 103
                                         )
104 104
                                     )
105 105
                                 );
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
                             <?php
112 112
 
113 113
                                 // Dynamic pricing.
114
-                                if( $item->supports_dynamic_pricing() ) {
114
+                                if ($item->supports_dynamic_pricing()) {
115 115
 
116
-                                    do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
116
+                                    do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item);
117 117
 
118 118
                                     // NYP toggle.
119 119
                                     echo aui()->input(
@@ -121,31 +121,31 @@  discard block
 block discarded – undo
121 121
                                             'id'          => 'wpinv_name_your_price',
122 122
                                             'name'        => 'wpinv_name_your_price',
123 123
                                             'type'        => 'checkbox',
124
-                                            'label'       => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
124
+                                            'label'       => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')),
125 125
                                             'value'       => '1',
126 126
                                             'checked'     => $item->user_can_set_their_price(),
127 127
                                             'no_wrap'     => true,
128 128
                                         )
129 129
                                     );
130 130
 
131
-                                    do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
131
+                                    do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item);
132 132
 
133 133
                                 }
134 134
 
135 135
                                 // Subscriptions.
136
-                                do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item );
136
+                                do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item);
137 137
                                 echo aui()->input(
138 138
                                     array(
139 139
                                         'id'          => 'wpinv_is_recurring',
140 140
                                         'name'        => 'wpinv_is_recurring',
141 141
                                         'type'        => 'checkbox',
142
-                                        'label'       => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ),
142
+                                        'label'       => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')),
143 143
                                         'value'       => '1',
144 144
                                         'checked'     => $item->is_recurring(),
145 145
                                         'no_wrap'     => true,
146 146
                                     )
147 147
                                 );
148
-                                do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item );
148
+                                do_action('wpinv_item_details_metabox_subscription_checkbox', $item);
149 149
 
150 150
                             ?>
151 151
                             <div class="wpinv_show_if_recurring">
@@ -155,30 +155,30 @@  discard block
 block discarded – undo
155 155
                     </div>
156 156
                 </div>
157 157
                 <div class="col-sm-1 pt-2 pl-0">
158
-                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span>
158
+                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span>
159 159
                 </div>
160 160
             </div>
161
-            <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?>
161
+            <?php do_action('wpinv_item_details_metabox_after_price', $item); ?>
162 162
 
163
-            <?php if( $item->supports_dynamic_pricing() ) : ?>
164
-                <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?>
163
+            <?php if ($item->supports_dynamic_pricing()) : ?>
164
+                <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?>
165 165
                 <div class="wpinv_show_if_dynamic wpinv_minimum_price">
166 166
 
167 167
                     <div class="form-group row">
168 168
                         <label for="wpinv_minimum_price" class="col-sm-3 col-form-label">
169
-                            <?php _e( 'Minimum Price', 'invoicing' );?>
169
+                            <?php _e('Minimum Price', 'invoicing'); ?>
170 170
                         </label>
171 171
                         <div class="col-sm-8">
172 172
                             <div class="input-group input-group-sm">
173
-                                <?php if( 'left' == $position ) : ?>
173
+                                <?php if ('left' == $position) : ?>
174 174
                                     <div class="input-group-prepend">
175 175
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
176 176
                                     </div>
177 177
                                 <?php endif; ?>
178 178
 
179
-                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
179
+                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
180 180
 
181
-                                <?php if( 'left' != $position ) : ?>
181
+                                <?php if ('left' != $position) : ?>
182 182
                                     <div class="input-group-append">
183 183
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
184 184
                                     </div>
@@ -187,45 +187,45 @@  discard block
 block discarded – undo
187 187
                         </div>
188 188
 
189 189
                         <div class="col-sm-1 pt-2 pl-0">
190
-                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span>
190
+                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span>
191 191
                         </div>
192 192
                     </div>
193 193
 
194 194
                 </div>
195
-                <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?>
195
+                <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?>
196 196
             <?php endif; ?>
197 197
 
198
-            <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?>
198
+            <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?>
199 199
             <div class="wpinv_show_if_recurring wpinv_maximum_renewals">
200 200
 
201 201
                 <div class="form-group row">
202 202
                     <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label">
203
-                        <?php _e( 'Maximum Renewals', 'invoicing' );?>
203
+                        <?php _e('Maximum Renewals', 'invoicing'); ?>
204 204
                     </label>
205 205
                     <div class="col-sm-8">
206
-                        <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
206
+                        <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
207 207
                     </div>
208 208
                     <div class="col-sm-1 pt-2 pl-0">
209
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span>
209
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span>
210 210
                     </div>
211 211
                 </div>
212 212
 
213 213
             </div>
214
-            <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?>
214
+            <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?>
215 215
 
216
-            <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?>
216
+            <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?>
217 217
             <div class="wpinv_show_if_recurring wpinv_free_trial">
218 218
 
219 219
                 <div class="form-group row">
220
-                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined( 'GETPAID_PAID_TRIALS_VERSION' ) ? _e( 'Free/Paid Trial', 'invoicing' ) : _e( 'Free Trial', 'invoicing' )?></label>
220
+                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined('GETPAID_PAID_TRIALS_VERSION') ? _e('Free/Paid Trial', 'invoicing') : _e('Free Trial', 'invoicing')?></label>
221 221
 
222 222
                     <div class="col-sm-8">
223 223
                         <div class="row">
224 224
                             <div class="col-sm-6">
225
-                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?>
225
+                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?>
226 226
 
227 227
                                 <div>
228
-                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" >
228
+                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" >
229 229
                                 </div>
230 230
                             </div>
231 231
                             <div class="col-sm-6">
@@ -234,17 +234,17 @@  discard block
 block discarded – undo
234 234
                                         array(
235 235
                                             'id'               => 'wpinv_trial_period',
236 236
                                             'name'             => 'wpinv_trial_period',
237
-                                            'label'            => __( 'Trial Period', 'invoicing' ),
238
-                                            'placeholder'      => __( 'Trial Period', 'invoicing' ),
239
-                                            'value'            => $item->get_trial_period( 'edit' ),
237
+                                            'label'            => __('Trial Period', 'invoicing'),
238
+                                            'placeholder'      => __('Trial Period', 'invoicing'),
239
+                                            'value'            => $item->get_trial_period('edit'),
240 240
                                             'select2'          => true,
241 241
                                             'data-allow-clear' => 'false',
242 242
                                             'no_wrap'          => true,
243 243
                                             'options'          => array(
244
-                                                'D'  => __( 'day(s)', 'invoicing' ),
245
-                                                'W'  => __( 'week(s)', 'invoicing' ),
246
-                                                'M'  => __( 'month(s)', 'invoicing' ),
247
-                                                'Y'  => __( 'year(s)', 'invoicing' ),
244
+                                                'D'  => __('day(s)', 'invoicing'),
245
+                                                'W'  => __('week(s)', 'invoicing'),
246
+                                                'M'  => __('month(s)', 'invoicing'),
247
+                                                'Y'  => __('year(s)', 'invoicing'),
248 248
                                             )
249 249
                                         )
250 250
                                     );
@@ -255,15 +255,15 @@  discard block
 block discarded – undo
255 255
                     </div>
256 256
 
257 257
                     <div class="col-sm-1 pt-2 pl-0">
258
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span>
258
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span>
259 259
                     </div>
260 260
 
261 261
                 </div>
262 262
 
263 263
             </div>
264
-            <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?>
264
+            <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?>
265 265
 
266
-            <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?>
266
+            <?php do_action('wpinv_item_details_metabox_item_details', $item); ?>
267 267
         </div>
268 268
         <?php
269 269
 
@@ -274,31 +274,31 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @param int $post_id
276 276
 	 */
277
-	public static function save( $post_id ) {
277
+	public static function save($post_id) {
278 278
 
279 279
         // Prepare the item.
280
-        $item = new WPInv_Item( $post_id );
280
+        $item = new WPInv_Item($post_id);
281 281
 
282 282
         // Load new data.
283 283
         $item->set_props(
284 284
 			array(
285
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
-				'is_dynamic_pricing'   => ! empty( $_POST['wpinv_name_your_price'] ),
290
-                'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
291
-				'is_recurring'         => ! empty( $_POST['wpinv_is_recurring'] ),
292
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
285
+				'price'                => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null,
286
+				'vat_rule'             => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null,
287
+				'vat_class'            => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null,
288
+				'type'                 => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null,
289
+				'is_dynamic_pricing'   => !empty($_POST['wpinv_name_your_price']),
290
+                'minimum_price'        => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null,
291
+				'is_recurring'         => !empty($_POST['wpinv_is_recurring']),
292
+				'recurring_period'     => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null,
293
+				'recurring_interval'   => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
+				'recurring_limit'      => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
+				'is_free_trial'        => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null,
296
+				'trial_period'         => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null,
297
+				'trial_interval'       => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null,
298 298
 			)
299 299
         );
300 300
 
301 301
 		$item->save();
302
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
302
+		do_action('getpaid_item_metabox_save', $post_id, $item);
303 303
 	}
304 304
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-discount-details.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Discount_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the discount.
@@ -396,35 +396,35 @@  discard block
 block discarded – undo
396 396
     }
397 397
 
398 398
     /**
399
-	 * Save meta box data.
400
-	 *
401
-	 * @param int $post_id
402
-	 */
403
-	public static function save( $post_id ) {
399
+     * Save meta box data.
400
+     *
401
+     * @param int $post_id
402
+     */
403
+    public static function save( $post_id ) {
404 404
 
405 405
         // Prepare the discount.
406 406
         $discount = new WPInv_Discount( $post_id );
407 407
 
408 408
         // Load new data.
409 409
         $discount->set_props(
410
-			array(
411
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null,
412
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null,
413
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
414
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
415
-				'is_single_use'        => ! empty( $_POST['wpinv_discount_single_use'] ),
410
+            array(
411
+                'code'                 => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null,
412
+                'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null,
413
+                'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
414
+                'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
415
+                'is_single_use'        => ! empty( $_POST['wpinv_discount_single_use'] ),
416 416
                 'type'                 => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null,
417
-				'is_recurring'         => ! empty( $_POST['wpinv_discount_recurring'] ),
418
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(),
419
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(),
417
+                'is_recurring'         => ! empty( $_POST['wpinv_discount_recurring'] ),
418
+                'items'                => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(),
419
+                'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(),
420 420
                 'required_items'       => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(),
421
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null,
422
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null,
423
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null,
424
-			)
421
+                'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null,
422
+                'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null,
423
+                'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null,
424
+            )
425 425
         );
426 426
 
427
-		$discount->save();
428
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
429
-	}
427
+        $discount->save();
428
+        do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
429
+    }
430 430
 }
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,24 +21,24 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the discount.
27
-        $discount = new WPInv_Discount( $post );
27
+        $discount = new WPInv_Discount($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32
-        do_action( 'wpinv_discount_form_top', $discount );
32
+        do_action('wpinv_discount_form_top', $discount);
33 33
 
34 34
         // Set the currency position.
35 35
         $position = wpinv_currency_position();
36 36
 
37
-        if ( $position == 'left_space' ) {
37
+        if ($position == 'left_space') {
38 38
             $position = 'left';
39 39
         }
40 40
 
41
-        if ( $position == 'right_space' ) {
41
+        if ($position == 'right_space') {
42 42
             $position = 'right';
43 43
         }
44 44
 
@@ -52,66 +52,66 @@  discard block
 block discarded – undo
52 52
         </style>
53 53
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
54 54
 
55
-            <?php do_action( 'wpinv_discount_form_first', $discount ); ?>
55
+            <?php do_action('wpinv_discount_form_first', $discount); ?>
56 56
 
57
-            <?php do_action( 'wpinv_discount_form_before_code', $discount ); ?>
57
+            <?php do_action('wpinv_discount_form_before_code', $discount); ?>
58 58
             <div class="form-group row">
59 59
                 <label for="wpinv_discount_code" class="col-sm-3 col-form-label">
60
-                    <?php _e( 'Discount Code', 'invoicing' );?>
60
+                    <?php _e('Discount Code', 'invoicing'); ?>
61 61
                 </label>
62 62
                 <div class="col-sm-8">
63 63
                     <div class="row">
64 64
                         <div class="col-sm-12 form-group">
65
-                            <input type="text" value="<?php echo esc_attr( $discount->get_code( 'edit' ) ); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
65
+                            <input type="text" value="<?php echo esc_attr($discount->get_code('edit')); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" />
66 66
                         </div>
67 67
                         <div class="col-sm-12">
68 68
                             <?php
69
-                                do_action( 'wpinv_discount_form_before_single_use', $discount );
69
+                                do_action('wpinv_discount_form_before_single_use', $discount);
70 70
 
71 71
                                 echo aui()->input(
72 72
                                     array(
73 73
                                         'id'          => 'wpinv_discount_single_use',
74 74
                                         'name'        => 'wpinv_discount_single_use',
75 75
                                         'type'        => 'checkbox',
76
-                                        'label'       => __( 'Each customer can only use this discount once', 'invoicing' ),
76
+                                        'label'       => __('Each customer can only use this discount once', 'invoicing'),
77 77
                                         'value'       => '1',
78 78
                                         'checked'     => $discount->is_single_use(),
79 79
                                     )
80 80
                                 );
81 81
 
82
-                                do_action( 'wpinv_discount_form_single_use', $discount );
82
+                                do_action('wpinv_discount_form_single_use', $discount);
83 83
                             ?>
84 84
                         </div>
85 85
                         <div class="col-sm-12">
86 86
                             <?php
87
-                                do_action( 'wpinv_discount_form_before_recurring', $discount );
87
+                                do_action('wpinv_discount_form_before_recurring', $discount);
88 88
 
89 89
                                 echo aui()->input(
90 90
                                     array(
91 91
                                         'id'          => 'wpinv_discount_recurring',
92 92
                                         'name'        => 'wpinv_discount_recurring',
93 93
                                         'type'        => 'checkbox',
94
-                                        'label'       => __( 'Apply this discount to all recurring payments for subscriptions', 'invoicing' ),
94
+                                        'label'       => __('Apply this discount to all recurring payments for subscriptions', 'invoicing'),
95 95
                                         'value'       => '1',
96 96
                                         'checked'     => $discount->is_recurring(),
97 97
                                     )
98 98
                                 );
99 99
 
100
-                                do_action( 'wpinv_discount_form_recurring', $discount );
100
+                                do_action('wpinv_discount_form_recurring', $discount);
101 101
                             ?>
102 102
                         </div>
103 103
                     </div>
104 104
                 </div>
105 105
                 <div class="col-sm-1 pt-2 pl-0">
106
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter a discount code such as 10OFF.', 'invoicing' ); ?>"></span>
106
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter a discount code such as 10OFF.', 'invoicing'); ?>"></span>
107 107
                 </div>
108 108
             </div>
109
-            <?php do_action( 'wpinv_discount_form_code', $discount ); ?>
109
+            <?php do_action('wpinv_discount_form_code', $discount); ?>
110 110
 
111
-            <?php do_action( 'wpinv_discount_form_before_type', $discount ); ?>
111
+            <?php do_action('wpinv_discount_form_before_type', $discount); ?>
112 112
             <div class="form-group row">
113 113
                 <label for="wpinv_discount_type" class="col-sm-3 col-form-label">
114
-                    <?php _e( 'Discount Type', 'invoicing' );?>
114
+                    <?php _e('Discount Type', 'invoicing'); ?>
115 115
                 </label>
116 116
                 <div class="col-sm-8">
117 117
                     <?php
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
                             array(
120 120
                                 'id'               => 'wpinv_discount_type',
121 121
                                 'name'             => 'wpinv_discount_type',
122
-                                'label'            => __( 'Discount Type', 'invoicing' ),
123
-                                'placeholder'      => __( 'Select Discount Type', 'invoicing' ),
124
-                                'value'            => $discount->get_type( 'edit' ),
122
+                                'label'            => __('Discount Type', 'invoicing'),
123
+                                'placeholder'      => __('Select Discount Type', 'invoicing'),
124
+                                'value'            => $discount->get_type('edit'),
125 125
                                 'select2'          => true,
126 126
                                 'data-allow-clear' => 'false',
127 127
                                 'options'          => wpinv_get_discount_types()
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
                     ?>
131 131
                 </div>
132 132
                 <div class="col-sm-1 pt-2 pl-0">
133
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Discount type.', 'invoicing' ); ?>"></span>
133
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Discount type.', 'invoicing'); ?>"></span>
134 134
                 </div>
135 135
             </div>
136
-            <?php do_action( 'wpinv_discount_form_type', $discount ); ?>
136
+            <?php do_action('wpinv_discount_form_type', $discount); ?>
137 137
 
138
-            <?php do_action( 'wpinv_discount_form_before_amount', $discount ); ?>
139
-            <div class="form-group row <?php echo esc_attr( $discount->get_type( 'edit' ) ); ?>" id="wpinv_discount_amount_wrap">
138
+            <?php do_action('wpinv_discount_form_before_amount', $discount); ?>
139
+            <div class="form-group row <?php echo esc_attr($discount->get_type('edit')); ?>" id="wpinv_discount_amount_wrap">
140 140
                 <label for="wpinv_discount_amount" class="col-sm-3 col-form-label">
141
-                    <?php _e( 'Discount Amount', 'invoicing' );?>
141
+                    <?php _e('Discount Amount', 'invoicing'); ?>
142 142
                 </label>
143 143
                 <div class="col-sm-8">
144 144
                     <div class="input-group input-group-sm">
145
-                        <?php if( 'left' == $position ) : ?>
145
+                        <?php if ('left' == $position) : ?>
146 146
                             <div class="input-group-prepend left wpinv-if-flat">
147 147
                                 <span class="input-group-text">
148 148
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
                             </div>
151 151
                         <?php endif; ?>
152 152
 
153
-                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr( $discount->get_amount( 'edit' ) ); ?>" placeholder="0" class="form-control">
153
+                        <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr($discount->get_amount('edit')); ?>" placeholder="0" class="form-control">
154 154
 
155
-                        <?php if( 'right' == $position ) : ?>
155
+                        <?php if ('right' == $position) : ?>
156 156
                             <div class="input-group-prepend left wpinv-if-flat">
157 157
                                 <span class="input-group-text">
158 158
                                     <?php echo wpinv_currency_symbol(); ?>
@@ -165,15 +165,15 @@  discard block
 block discarded – undo
165 165
                     </div>
166 166
                 </div>
167 167
                 <div class="col-sm-1 pt-2 pl-0">
168
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?>"></span>
168
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the discount value. Ex: 10', 'invoicing'); ?>"></span>
169 169
                 </div>
170 170
             </div>
171
-            <?php do_action( 'wpinv_discount_form_amount', $discount ); ?>
171
+            <?php do_action('wpinv_discount_form_amount', $discount); ?>
172 172
 
173
-            <?php do_action( 'wpinv_discount_form_before_items', $discount ); ?>
173
+            <?php do_action('wpinv_discount_form_before_items', $discount); ?>
174 174
             <div class="form-group row">
175 175
                 <label for="wpinv_discount_items" class="col-sm-3 col-form-label">
176
-                    <?php _e( 'Items', 'invoicing' );?>
176
+                    <?php _e('Items', 'invoicing'); ?>
177 177
                 </label>
178 178
                 <div class="col-sm-8">
179 179
                     <?php
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
                             array(
182 182
                                 'id'               => 'wpinv_discount_items',
183 183
                                 'name'             => 'wpinv_discount_items[]',
184
-                                'label'            => __( 'Items', 'invoicing' ),
185
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
186
-                                'value'            => $discount->get_items( 'edit' ),
184
+                                'label'            => __('Items', 'invoicing'),
185
+                                'placeholder'      => __('Select Items', 'invoicing'),
186
+                                'value'            => $discount->get_items('edit'),
187 187
                                 'select2'          => true,
188 188
                                 'multiple'         => true,
189 189
                                 'data-allow-clear' => 'false',
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
                     ?>
194 194
                 </div>
195 195
                 <div class="col-sm-1 pt-2 pl-0">
196
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing' ); ?>"></span>
196
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing'); ?>"></span>
197 197
                 </div>
198 198
             </div>
199
-            <?php do_action( 'wpinv_discount_form_items', $discount ); ?>
199
+            <?php do_action('wpinv_discount_form_items', $discount); ?>
200 200
 
201
-            <?php do_action( 'wpinv_discount_form_before_excluded_items', $discount ); ?>
201
+            <?php do_action('wpinv_discount_form_before_excluded_items', $discount); ?>
202 202
             <div class="form-group row">
203 203
                 <label for="wpinv_discount_excluded_items" class="col-sm-3 col-form-label">
204
-                    <?php _e( 'Excluded Items', 'invoicing' );?>
204
+                    <?php _e('Excluded Items', 'invoicing'); ?>
205 205
                 </label>
206 206
                 <div class="col-sm-8">
207 207
                     <?php
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
                             array(
210 210
                                 'id'               => 'wpinv_discount_excluded_items',
211 211
                                 'name'             => 'wpinv_discount_excluded_items[]',
212
-                                'label'            => __( 'Excluded Items', 'invoicing' ),
213
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
214
-                                'value'            => $discount->get_excluded_items( 'edit' ),
212
+                                'label'            => __('Excluded Items', 'invoicing'),
213
+                                'placeholder'      => __('Select Items', 'invoicing'),
214
+                                'value'            => $discount->get_excluded_items('edit'),
215 215
                                 'select2'          => true,
216 216
                                 'multiple'         => true,
217 217
                                 'data-allow-clear' => 'false',
@@ -221,15 +221,15 @@  discard block
 block discarded – undo
221 221
                     ?>
222 222
                 </div>
223 223
                 <div class="col-sm-1 pt-2 pl-0">
224
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are not allowed to use this discount.', 'invoicing' ); ?>"></span>
224
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are not allowed to use this discount.', 'invoicing'); ?>"></span>
225 225
                 </div>
226 226
             </div>
227
-            <?php do_action( 'wpinv_discount_form_excluded_items', $discount ); ?>
227
+            <?php do_action('wpinv_discount_form_excluded_items', $discount); ?>
228 228
 
229
-            <?php do_action( 'wpinv_discount_form_before_required_items', $discount ); ?>
229
+            <?php do_action('wpinv_discount_form_before_required_items', $discount); ?>
230 230
             <div class="form-group row">
231 231
                 <label for="wpinv_discount_required_items" class="col-sm-3 col-form-label">
232
-                    <?php _e( 'Required Items', 'invoicing' );?>
232
+                    <?php _e('Required Items', 'invoicing'); ?>
233 233
                 </label>
234 234
                 <div class="col-sm-8">
235 235
                     <?php
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
                             array(
238 238
                                 'id'               => 'wpinv_discount_required_items',
239 239
                                 'name'             => 'wpinv_discount_required_items[]',
240
-                                'label'            => __( 'Required Items', 'invoicing' ),
241
-                                'placeholder'      => __( 'Select Items', 'invoicing' ),
242
-                                'value'            => $discount->get_required_items( 'edit' ),
240
+                                'label'            => __('Required Items', 'invoicing'),
241
+                                'placeholder'      => __('Select Items', 'invoicing'),
242
+                                'value'            => $discount->get_required_items('edit'),
243 243
                                 'select2'          => true,
244 244
                                 'multiple'         => true,
245 245
                                 'data-allow-clear' => 'false',
@@ -249,15 +249,15 @@  discard block
 block discarded – undo
249 249
                     ?>
250 250
                 </div>
251 251
                 <div class="col-sm-1 pt-2 pl-0">
252
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are required to be in the cart before using this discount.', 'invoicing' ); ?>"></span>
252
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are required to be in the cart before using this discount.', 'invoicing'); ?>"></span>
253 253
                 </div>
254 254
             </div>
255
-            <?php do_action( 'wpinv_discount_form_required_items', $discount ); ?>
255
+            <?php do_action('wpinv_discount_form_required_items', $discount); ?>
256 256
 
257
-            <?php do_action( 'wpinv_discount_form_before_start', $discount ); ?>
257
+            <?php do_action('wpinv_discount_form_before_start', $discount); ?>
258 258
             <div class="form-group row">
259 259
                 <label for="wpinv_discount_start" class="col-sm-3 col-form-label">
260
-                    <?php _e( 'Start Date', 'invoicing' );?>
260
+                    <?php _e('Start Date', 'invoicing'); ?>
261 261
                 </label>
262 262
                 <div class="col-sm-8">
263 263
                     <?php
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
                                 'type'        => 'datepicker',
267 267
                                 'id'          => 'wpinv_discount_start',
268 268
                                 'name'        => 'wpinv_discount_start',
269
-                                'label'       => __( 'Start Date', 'invoicing' ),
269
+                                'label'       => __('Start Date', 'invoicing'),
270 270
                                 'placeholder' => 'YYYY-MM-DD 00:00',
271 271
                                 'class'       => 'form-control-sm',
272
-                                'value'       => $discount->get_start_date( 'edit' ),
272
+                                'value'       => $discount->get_start_date('edit'),
273 273
                                 'extra_attributes' => array(
274 274
                                     'data-enable-time' => 'true',
275 275
                                     'data-time_24hr'   => 'true',
@@ -280,15 +280,15 @@  discard block
 block discarded – undo
280 280
                     ?>
281 281
                 </div>
282 282
                 <div class="col-sm-1 pt-2 pl-0">
283
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?>"></span>
283
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?>"></span>
284 284
                 </div>
285 285
             </div>
286
-            <?php do_action( 'wpinv_discount_form_start', $discount ); ?>
286
+            <?php do_action('wpinv_discount_form_start', $discount); ?>
287 287
 
288
-            <?php do_action( 'wpinv_discount_form_before_expiration', $discount ); ?>
288
+            <?php do_action('wpinv_discount_form_before_expiration', $discount); ?>
289 289
             <div class="form-group row">
290 290
                 <label for="wpinv_discount_expiration" class="col-sm-3 col-form-label">
291
-                    <?php _e( 'Expiration Date', 'invoicing' );?>
291
+                    <?php _e('Expiration Date', 'invoicing'); ?>
292 292
                 </label>
293 293
                 <div class="col-sm-8">
294 294
                     <?php
@@ -297,10 +297,10 @@  discard block
 block discarded – undo
297 297
                                 'type'        => 'datepicker',
298 298
                                 'id'          => 'wpinv_discount_expiration',
299 299
                                 'name'        => 'wpinv_discount_expiration',
300
-                                'label'       => __( 'Expiration Date', 'invoicing' ),
300
+                                'label'       => __('Expiration Date', 'invoicing'),
301 301
                                 'placeholder' => 'YYYY-MM-DD 00:00',
302 302
                                 'class'       => 'form-control-sm',
303
-                                'value'       => $discount->get_end_date( 'edit' ),
303
+                                'value'       => $discount->get_end_date('edit'),
304 304
                                 'extra_attributes' => array(
305 305
                                     'data-enable-time' => 'true',
306 306
                                     'data-time_24hr'   => 'true',
@@ -313,27 +313,27 @@  discard block
 block discarded – undo
313 313
                     ?>
314 314
                 </div>
315 315
                 <div class="col-sm-1 pt-2 pl-0">
316
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the date after which the discount will expire.', 'invoicing' ); ?>"></span>
316
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the date after which the discount will expire.', 'invoicing'); ?>"></span>
317 317
                 </div>
318 318
             </div>
319
-            <?php do_action( 'wpinv_discount_form_expiration', $discount ); ?>
319
+            <?php do_action('wpinv_discount_form_expiration', $discount); ?>
320 320
 
321
-            <?php do_action( 'wpinv_discount_form_before_min_total', $discount ); ?>
321
+            <?php do_action('wpinv_discount_form_before_min_total', $discount); ?>
322 322
             <div class="form-group row">
323 323
                 <label for="wpinv_discount_min_total" class="col-sm-3 col-form-label">
324
-                    <?php _e( 'Minimum Amount', 'invoicing' );?>
324
+                    <?php _e('Minimum Amount', 'invoicing'); ?>
325 325
                 </label>
326 326
                 <div class="col-sm-8">
327 327
                     <div class="input-group input-group-sm">
328
-                        <?php if( 'left' == $position ) : ?>
328
+                        <?php if ('left' == $position) : ?>
329 329
                             <div class="input-group-prepend">
330 330
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
331 331
                             </div>
332 332
                         <?php endif; ?>
333 333
 
334
-                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr( $discount->get_minimum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No minimum', 'invoicing' ); ?>" class="form-control">
334
+                        <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr($discount->get_minimum_total('edit')); ?>" placeholder="<?php esc_attr_e('No minimum', 'invoicing'); ?>" class="form-control">
335 335
 
336
-                        <?php if( 'left' != $position ) : ?>
336
+                        <?php if ('left' != $position) : ?>
337 337
                             <div class="input-group-append">
338 338
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
339 339
                             </div>
@@ -341,27 +341,27 @@  discard block
 block discarded – undo
341 341
                     </div>
342 342
                 </div>
343 343
                 <div class="col-sm-1 pt-2 pl-0">
344
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing' ); ?>"></span>
344
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing'); ?>"></span>
345 345
                 </div>
346 346
             </div>
347
-            <?php do_action( 'wpinv_discount_form_min_total', $discount ); ?>
347
+            <?php do_action('wpinv_discount_form_min_total', $discount); ?>
348 348
 
349
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
349
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
350 350
             <div class="form-group row">
351 351
                 <label for="wpinv_discount_max_total" class="col-sm-3 col-form-label">
352
-                    <?php _e( 'Maximum Amount', 'invoicing' );?>
352
+                    <?php _e('Maximum Amount', 'invoicing'); ?>
353 353
                 </label>
354 354
                 <div class="col-sm-8">
355 355
                     <div class="input-group input-group-sm">
356
-                        <?php if( 'left' == $position ) : ?>
356
+                        <?php if ('left' == $position) : ?>
357 357
                             <div class="input-group-prepend">
358 358
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
359 359
                             </div>
360 360
                         <?php endif; ?>
361 361
 
362
-                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr( $discount->get_maximum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No maximum', 'invoicing' ); ?>" class="form-control">
362
+                        <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr($discount->get_maximum_total('edit')); ?>" placeholder="<?php esc_attr_e('No maximum', 'invoicing'); ?>" class="form-control">
363 363
 
364
-                        <?php if( 'left' != $position ) : ?>
364
+                        <?php if ('left' != $position) : ?>
365 365
                             <div class="input-group-append">
366 366
                                 <span class="input-group-text"><?php echo wpinv_currency_symbol(); ?></span>
367 367
                             </div>
@@ -369,30 +369,30 @@  discard block
 block discarded – undo
369 369
                     </div>
370 370
                 </div>
371 371
                 <div class="col-sm-1 pt-2 pl-0">
372
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing' ); ?>"></span>
372
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing'); ?>"></span>
373 373
                 </div>
374 374
             </div>
375
-            <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?>
375
+            <?php do_action('wpinv_discount_form_before_max_total', $discount); ?>
376 376
 
377
-            <?php do_action( 'wpinv_discount_form_before_max_uses', $discount ); ?>
377
+            <?php do_action('wpinv_discount_form_before_max_uses', $discount); ?>
378 378
             <div class="form-group row">
379 379
                 <label for="wpinv_discount_max_uses" class="col-sm-3 col-form-label">
380
-                    <?php _e( 'Maximum Uses', 'invoicing' );?>
380
+                    <?php _e('Maximum Uses', 'invoicing'); ?>
381 381
                 </label>
382 382
                 <div class="col-sm-8">
383
-                    <input type="text" value="<?php echo esc_attr( $discount->get_max_uses( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'invoicing' ); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
383
+                    <input type="text" value="<?php echo esc_attr($discount->get_max_uses('edit')); ?>" placeholder="<?php esc_attr_e('Unlimited', 'invoicing'); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" />
384 384
                 </div>
385 385
                 <div class="col-sm-1 pt-2 pl-0">
386
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum number of times that this discount code can be used.', 'invoicing' ); ?>"></span>
386
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum number of times that this discount code can be used.', 'invoicing'); ?>"></span>
387 387
                 </div>
388 388
             </div>
389
-            <?php do_action( 'wpinv_discount_form_max_uses', $discount ); ?>
389
+            <?php do_action('wpinv_discount_form_max_uses', $discount); ?>
390 390
 
391
-            <?php do_action( 'wpinv_discount_form_last', $discount ); ?>
391
+            <?php do_action('wpinv_discount_form_last', $discount); ?>
392 392
 
393 393
         </div>
394 394
         <?php
395
-        do_action( 'wpinv_discount_form_bottom', $post );
395
+        do_action('wpinv_discount_form_bottom', $post);
396 396
     }
397 397
 
398 398
     /**
@@ -400,31 +400,31 @@  discard block
 block discarded – undo
400 400
 	 *
401 401
 	 * @param int $post_id
402 402
 	 */
403
-	public static function save( $post_id ) {
403
+	public static function save($post_id) {
404 404
 
405 405
         // Prepare the discount.
406
-        $discount = new WPInv_Discount( $post_id );
406
+        $discount = new WPInv_Discount($post_id);
407 407
 
408 408
         // Load new data.
409 409
         $discount->set_props(
410 410
 			array(
411
-				'code'                 => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null,
412
-				'amount'               => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null,
413
-				'start'                => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null,
414
-				'expiration'           => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null,
415
-				'is_single_use'        => ! empty( $_POST['wpinv_discount_single_use'] ),
416
-                'type'                 => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null,
417
-				'is_recurring'         => ! empty( $_POST['wpinv_discount_recurring'] ),
418
-				'items'                => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(),
419
-				'excluded_items'       => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(),
420
-                'required_items'       => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(),
421
-				'max_uses'             => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null,
422
-				'min_total'            => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null,
423
-				'max_total'            => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null,
411
+				'code'                 => isset($_POST['wpinv_discount_code']) ? wpinv_clean($_POST['wpinv_discount_code']) : null,
412
+				'amount'               => isset($_POST['wpinv_discount_amount']) ? floatval($_POST['wpinv_discount_amount']) : null,
413
+				'start'                => isset($_POST['wpinv_discount_start']) ? wpinv_clean($_POST['wpinv_discount_start']) : null,
414
+				'expiration'           => isset($_POST['wpinv_discount_expiration']) ? wpinv_clean($_POST['wpinv_discount_expiration']) : null,
415
+				'is_single_use'        => !empty($_POST['wpinv_discount_single_use']),
416
+                'type'                 => isset($_POST['wpinv_discount_type']) ? wpinv_clean($_POST['wpinv_discount_type']) : null,
417
+				'is_recurring'         => !empty($_POST['wpinv_discount_recurring']),
418
+				'items'                => isset($_POST['wpinv_discount_items']) ? wpinv_clean($_POST['wpinv_discount_items']) : array(),
419
+				'excluded_items'       => isset($_POST['wpinv_discount_excluded_items']) ? wpinv_clean($_POST['wpinv_discount_excluded_items']) : array(),
420
+                'required_items'       => isset($_POST['wpinv_discount_required_items']) ? wpinv_clean($_POST['wpinv_discount_required_items']) : array(),
421
+				'max_uses'             => isset($_POST['wpinv_discount_max_uses']) ? intval($_POST['wpinv_discount_max_uses']) : null,
422
+				'min_total'            => isset($_POST['wpinv_discount_min_total']) ? floatval($_POST['wpinv_discount_min_total']) : null,
423
+				'max_total'            => isset($_POST['wpinv_discount_max_total']) ? floatval($_POST['wpinv_discount_max_total']) : null,
424 424
 			)
425 425
         );
426 426
 
427 427
 		$discount->save();
428
-		do_action( 'getpaid_discount_metabox_save', $post_id, $discount );
428
+		do_action('getpaid_discount_metabox_save', $post_id, $discount);
429 429
 	}
430 430
 }
Please login to merge, or discard this patch.