Passed
Push — master ( 1b8ab4...0cc6c6 )
by Brian
10:37 queued 05:47
created
includes/class-wpinv.php 1 patch
Indentation   +564 added lines, -564 removed lines patch added patch discarded remove patch
@@ -14,615 +14,615 @@
 block discarded – undo
14 14
  */
15 15
 class WPInv_Plugin {
16 16
 
17
-	/**
18
-	 * GetPaid version.
19
-	 *
20
-	 * @var string
21
-	 */
22
-	public $version;
23
-
24
-	/**
25
-	 * Data container.
26
-	 *
27
-	 * @var array
28
-	 */
29
-	protected $data = array();
30
-
31
-	/**
32
-	 * Form elements instance.
33
-	 *
34
-	 * @var WPInv_Payment_Form_Elements
35
-	 */
36
-	public $form_elements;
37
-
38
-	/**
39
-	 * @var array An array of payment gateways.
40
-	 */
41
-	public $gateways;
42
-
43
-	/**
44
-	 * Class constructor.
45
-	 */
46
-	public function __construct() {
47
-		$this->define_constants();
48
-		$this->includes();
49
-		$this->init_hooks();
50
-		$this->set_properties();
51
-	}
52
-
53
-	/**
54
-	 * Sets a custom data property.
55
-	 *
56
-	 * @param string $prop The prop to set.
57
-	 * @param mixed $value The value to retrieve.
58
-	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
61
-	}
62
-
63
-	/**
64
-	 * Gets a custom data property.
65
-	 *
66
-	 * @param string $prop The prop to set.
67
-	 * @return mixed The value.
68
-	 */
69
-	public function get( $prop ) {
70
-
71
-		if ( isset( $this->data[ $prop ] ) ) {
72
-			return $this->data[ $prop ];
73
-		}
74
-
75
-		return null;
76
-	}
77
-
78
-	/**
79
-	 * Define class properties.
80
-	 */
81
-	public function set_properties() {
82
-
83
-		// Sessions.
84
-		$this->set( 'session', new WPInv_Session_Handler() );
85
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
86
-		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87
-
88
-		// Init other objects.
89
-		$this->set( 'session', new WPInv_Session_Handler() );
90
-		$this->set( 'notes', new WPInv_Notes() );
91
-		$this->set( 'api', new WPInv_API() );
92
-		$this->set( 'post_types', new GetPaid_Post_Types() );
93
-		$this->set( 'template', new GetPaid_Template() );
94
-		$this->set( 'admin', new GetPaid_Admin() );
95
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
96
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
97
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
98
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
99
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
100
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
101
-
102
-	}
103
-
104
-	 /**
105
-	 * Define plugin constants.
106
-	 */
107
-	public function define_constants() {
108
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
109
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
110
-		$this->version = WPINV_VERSION;
111
-	}
112
-
113
-	/**
114
-	 * Hook into actions and filters.
115
-	 *
116
-	 * @since 1.0.19
117
-	 */
118
-	protected function init_hooks() {
119
-		/* Internationalize the text strings used. */
120
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
121
-
122
-		// Init the plugin after WordPress inits.
123
-		add_action( 'init', array( $this, 'init' ), 1 );
124
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
125
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
126
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
127
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
128
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
129
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
130
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
131
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
132
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
133
-
134
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
17
+    /**
18
+     * GetPaid version.
19
+     *
20
+     * @var string
21
+     */
22
+    public $version;
23
+
24
+    /**
25
+     * Data container.
26
+     *
27
+     * @var array
28
+     */
29
+    protected $data = array();
30
+
31
+    /**
32
+     * Form elements instance.
33
+     *
34
+     * @var WPInv_Payment_Form_Elements
35
+     */
36
+    public $form_elements;
37
+
38
+    /**
39
+     * @var array An array of payment gateways.
40
+     */
41
+    public $gateways;
42
+
43
+    /**
44
+     * Class constructor.
45
+     */
46
+    public function __construct() {
47
+        $this->define_constants();
48
+        $this->includes();
49
+        $this->init_hooks();
50
+        $this->set_properties();
51
+    }
52
+
53
+    /**
54
+     * Sets a custom data property.
55
+     *
56
+     * @param string $prop The prop to set.
57
+     * @param mixed $value The value to retrieve.
58
+     */
59
+    public function set( $prop, $value ) {
60
+        $this->data[ $prop ] = $value;
61
+    }
62
+
63
+    /**
64
+     * Gets a custom data property.
65
+     *
66
+     * @param string $prop The prop to set.
67
+     * @return mixed The value.
68
+     */
69
+    public function get( $prop ) {
70
+
71
+        if ( isset( $this->data[ $prop ] ) ) {
72
+            return $this->data[ $prop ];
73
+        }
74
+
75
+        return null;
76
+    }
77
+
78
+    /**
79
+     * Define class properties.
80
+     */
81
+    public function set_properties() {
82
+
83
+        // Sessions.
84
+        $this->set( 'session', new WPInv_Session_Handler() );
85
+        $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
86
+        $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87
+
88
+        // Init other objects.
89
+        $this->set( 'session', new WPInv_Session_Handler() );
90
+        $this->set( 'notes', new WPInv_Notes() );
91
+        $this->set( 'api', new WPInv_API() );
92
+        $this->set( 'post_types', new GetPaid_Post_Types() );
93
+        $this->set( 'template', new GetPaid_Template() );
94
+        $this->set( 'admin', new GetPaid_Admin() );
95
+        $this->set( 'subscriptions', new WPInv_Subscriptions() );
96
+        $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
97
+        $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
98
+        $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
99
+        $this->set( 'payment_forms', new GetPaid_Payment_Forms() );
100
+        $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
101
+
102
+    }
103
+
104
+        /**
105
+         * Define plugin constants.
106
+         */
107
+    public function define_constants() {
108
+        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
109
+        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
110
+        $this->version = WPINV_VERSION;
111
+    }
112
+
113
+    /**
114
+     * Hook into actions and filters.
115
+     *
116
+     * @since 1.0.19
117
+     */
118
+    protected function init_hooks() {
119
+        /* Internationalize the text strings used. */
120
+        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
121
+
122
+        // Init the plugin after WordPress inits.
123
+        add_action( 'init', array( $this, 'init' ), 1 );
124
+        add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 );
125
+        add_action( 'init', array( $this, 'wpinv_actions' ) );
126
+        add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
127
+        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
128
+        add_action( 'wp_footer', array( $this, 'wp_footer' ) );
129
+        add_action( 'wp_head', array( $this, 'wp_head' ) );
130
+        add_action( 'widgets_init', array( $this, 'register_widgets' ) );
131
+        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
132
+        add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
133
+
134
+        add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
135 135
         add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
136
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
137
-
138
-		// Fires after registering actions.
139
-		do_action( 'wpinv_actions', $this );
140
-		do_action( 'getpaid_actions', $this );
141
-
142
-	}
143
-
144
-	public function plugins_loaded() {
145
-		/* Internationalize the text strings used. */
146
-		$this->load_textdomain();
147
-
148
-		do_action( 'wpinv_loaded' );
149
-
150
-		// Fix oxygen page builder conflict
151
-		if ( function_exists( 'ct_css_output' ) ) {
152
-			wpinv_oxygen_fix_conflict();
153
-		}
154
-	}
155
-
156
-	/**
157
-	 * Load Localisation files.
158
-	 *
159
-	 * Note: the first-loaded translation file overrides any following ones if the same translation is present.
160
-	 *
161
-	 * Locales found in:
162
-	 *      - WP_LANG_DIR/plugins/invoicing-LOCALE.mo
163
-	 *      - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo
164
-	 *
165
-	 * @since 1.0.0
166
-	 */
167
-	public function load_textdomain() {
168
-
169
-		load_plugin_textdomain(
170
-			'invoicing',
171
-			false,
172
-			plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/'
173
-		);
174
-
175
-	}
176
-
177
-	/**
178
-	 * Include required core files used in admin and on the frontend.
179
-	 */
180
-	public function includes() {
181
-
182
-		// Start with the settings.
183
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
184
-
185
-		// Packages/libraries.
186
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
187
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
188
-
189
-		// Load functions.
190
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
191
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
192
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
193
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
195
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
196
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
197
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
200
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
205
-
206
-		// Register autoloader.
207
-		try {
208
-			spl_autoload_register( array( $this, 'autoload' ), true );
209
-		} catch ( Exception $e ) {
210
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
211
-		}
212
-
213
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
216
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
217
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
218
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
219
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
220
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
221
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
222
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
234
-
235
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
236
-			GetPaid_Post_Types_Admin::init();
237
-
238
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
239
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
240
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
241
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
242
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
243
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
244
-			// load the user class only on the users.php page
245
-			global $pagenow;
246
-			if($pagenow=='users.php'){
247
-				new WPInv_Admin_Users();
248
-			}
249
-		}
250
-
251
-		// Register cli commands
252
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
253
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
254
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
255
-		}
256
-
257
-	}
258
-
259
-	/**
260
-	 * Class autoloader
261
-	 *
262
-	 * @param       string $class_name The name of the class to load.
263
-	 * @access      public
264
-	 * @since       1.0.19
265
-	 * @return      void
266
-	 */
267
-	public function autoload( $class_name ) {
268
-
269
-		// Normalize the class name...
270
-		$class_name  = strtolower( $class_name );
271
-
272
-		// ... and make sure it is our class.
273
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
274
-			return;
275
-		}
276
-
277
-		// Next, prepare the file name from the class.
278
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
279
-
280
-		// Base path of the classes.
281
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
282
-
283
-		// And an array of possible locations in order of importance.
284
-		$locations = array(
285
-			"$plugin_path/includes",
286
-			"$plugin_path/includes/data-stores",
287
-			"$plugin_path/includes/gateways",
288
-			"$plugin_path/includes/payments",
289
-			"$plugin_path/includes/geolocation",
290
-			"$plugin_path/includes/reports",
291
-			"$plugin_path/includes/api",
292
-			"$plugin_path/includes/admin",
293
-			"$plugin_path/includes/admin/meta-boxes",
294
-		);
295
-
296
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
297
-
298
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
299
-				include trailingslashit( $location ) . $file_name;
300
-				break;
301
-			}
302
-
303
-		}
304
-
305
-	}
306
-
307
-	/**
308
-	 * Inits hooks etc.
309
-	 */
310
-	public function init() {
311
-
312
-		// Fires before getpaid inits.
313
-		do_action( 'before_getpaid_init', $this );
314
-
315
-		// Maybe upgrade.
316
-		$this->maybe_upgrade_database();
317
-
318
-		// Load default gateways.
319
-		$gateways = apply_filters(
320
-			'getpaid_default_gateways',
321
-			array(
322
-				'manual'        => 'GetPaid_Manual_Gateway',
323
-				'paypal'        => 'GetPaid_Paypal_Gateway',
324
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
325
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
326
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
327
-			)
328
-		);
329
-
330
-		foreach ( $gateways as $id => $class ) {
331
-			$this->gateways[ $id ] = new $class();
332
-		}
333
-
334
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
-			GetPaid_Installer::rename_gateways_label();
336
-			update_option( 'wpinv_renamed_gateways', 'yes' );
337
-		}
338
-
339
-		// Fires after getpaid inits.
340
-		do_action( 'getpaid_init', $this );
341
-
342
-	}
343
-
344
-	/**
345
-	 * Checks if this is an IPN request and processes it.
346
-	 */
347
-	public function maybe_process_ipn() {
348
-
349
-		// Ensure that this is an IPN request.
350
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
351
-			return;
352
-		}
353
-
354
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
355
-
356
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
357
-		do_action( "wpinv_verify_{$gateway}_ipn" );
358
-		exit;
359
-
360
-	}
361
-
362
-	public function enqueue_scripts() {
363
-
364
-		// Fires before adding scripts.
365
-		do_action( 'getpaid_enqueue_scripts' );
366
-
367
-		$localize                         = array();
368
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
369
-		$localize['thousands']            = wpinv_thousands_separator();
370
-		$localize['decimals']             = wpinv_decimal_separator();
371
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
372
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
373
-		$localize['UseTaxes']             = wpinv_use_taxes();
374
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
375
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
376
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
377
-
378
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
379
-
380
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
381
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
382
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
383
-	}
384
-
385
-	public function wpinv_actions() {
386
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
387
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
388
-		}
389
-	}
390
-
391
-	/**
136
+        add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
137
+
138
+        // Fires after registering actions.
139
+        do_action( 'wpinv_actions', $this );
140
+        do_action( 'getpaid_actions', $this );
141
+
142
+    }
143
+
144
+    public function plugins_loaded() {
145
+        /* Internationalize the text strings used. */
146
+        $this->load_textdomain();
147
+
148
+        do_action( 'wpinv_loaded' );
149
+
150
+        // Fix oxygen page builder conflict
151
+        if ( function_exists( 'ct_css_output' ) ) {
152
+            wpinv_oxygen_fix_conflict();
153
+        }
154
+    }
155
+
156
+    /**
157
+     * Load Localisation files.
158
+     *
159
+     * Note: the first-loaded translation file overrides any following ones if the same translation is present.
160
+     *
161
+     * Locales found in:
162
+     *      - WP_LANG_DIR/plugins/invoicing-LOCALE.mo
163
+     *      - WP_PLUGIN_DIR/invoicing/languages/invoicing-LOCALE.mo
164
+     *
165
+     * @since 1.0.0
166
+     */
167
+    public function load_textdomain() {
168
+
169
+        load_plugin_textdomain(
170
+            'invoicing',
171
+            false,
172
+            plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/'
173
+        );
174
+
175
+    }
176
+
177
+    /**
178
+     * Include required core files used in admin and on the frontend.
179
+     */
180
+    public function includes() {
181
+
182
+        // Start with the settings.
183
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
184
+
185
+        // Packages/libraries.
186
+        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
187
+        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
188
+
189
+        // Load functions.
190
+        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
191
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
192
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
193
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
194
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
195
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
196
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
197
+        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
198
+        require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
199
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
200
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
201
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
202
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
203
+        require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
204
+        require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
205
+
206
+        // Register autoloader.
207
+        try {
208
+            spl_autoload_register( array( $this, 'autoload' ), true );
209
+        } catch ( Exception $e ) {
210
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
211
+        }
212
+
213
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
214
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
215
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
216
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
217
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
218
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
219
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
220
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
221
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
222
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
223
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
224
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
225
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
226
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
227
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
228
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
229
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
230
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
231
+        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
232
+        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
233
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
234
+
235
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
236
+            GetPaid_Post_Types_Admin::init();
237
+
238
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
239
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
240
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
241
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
242
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
243
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
244
+            // load the user class only on the users.php page
245
+            global $pagenow;
246
+            if($pagenow=='users.php'){
247
+                new WPInv_Admin_Users();
248
+            }
249
+        }
250
+
251
+        // Register cli commands
252
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
253
+            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
254
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
255
+        }
256
+
257
+    }
258
+
259
+    /**
260
+     * Class autoloader
261
+     *
262
+     * @param       string $class_name The name of the class to load.
263
+     * @access      public
264
+     * @since       1.0.19
265
+     * @return      void
266
+     */
267
+    public function autoload( $class_name ) {
268
+
269
+        // Normalize the class name...
270
+        $class_name  = strtolower( $class_name );
271
+
272
+        // ... and make sure it is our class.
273
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
274
+            return;
275
+        }
276
+
277
+        // Next, prepare the file name from the class.
278
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
279
+
280
+        // Base path of the classes.
281
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
282
+
283
+        // And an array of possible locations in order of importance.
284
+        $locations = array(
285
+            "$plugin_path/includes",
286
+            "$plugin_path/includes/data-stores",
287
+            "$plugin_path/includes/gateways",
288
+            "$plugin_path/includes/payments",
289
+            "$plugin_path/includes/geolocation",
290
+            "$plugin_path/includes/reports",
291
+            "$plugin_path/includes/api",
292
+            "$plugin_path/includes/admin",
293
+            "$plugin_path/includes/admin/meta-boxes",
294
+        );
295
+
296
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
297
+
298
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
299
+                include trailingslashit( $location ) . $file_name;
300
+                break;
301
+            }
302
+
303
+        }
304
+
305
+    }
306
+
307
+    /**
308
+     * Inits hooks etc.
309
+     */
310
+    public function init() {
311
+
312
+        // Fires before getpaid inits.
313
+        do_action( 'before_getpaid_init', $this );
314
+
315
+        // Maybe upgrade.
316
+        $this->maybe_upgrade_database();
317
+
318
+        // Load default gateways.
319
+        $gateways = apply_filters(
320
+            'getpaid_default_gateways',
321
+            array(
322
+                'manual'        => 'GetPaid_Manual_Gateway',
323
+                'paypal'        => 'GetPaid_Paypal_Gateway',
324
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
325
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
326
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
327
+            )
328
+        );
329
+
330
+        foreach ( $gateways as $id => $class ) {
331
+            $this->gateways[ $id ] = new $class();
332
+        }
333
+
334
+        if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
+            GetPaid_Installer::rename_gateways_label();
336
+            update_option( 'wpinv_renamed_gateways', 'yes' );
337
+        }
338
+
339
+        // Fires after getpaid inits.
340
+        do_action( 'getpaid_init', $this );
341
+
342
+    }
343
+
344
+    /**
345
+     * Checks if this is an IPN request and processes it.
346
+     */
347
+    public function maybe_process_ipn() {
348
+
349
+        // Ensure that this is an IPN request.
350
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
351
+            return;
352
+        }
353
+
354
+        $gateway = wpinv_clean( $_GET['wpi-gateway'] );
355
+
356
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
357
+        do_action( "wpinv_verify_{$gateway}_ipn" );
358
+        exit;
359
+
360
+    }
361
+
362
+    public function enqueue_scripts() {
363
+
364
+        // Fires before adding scripts.
365
+        do_action( 'getpaid_enqueue_scripts' );
366
+
367
+        $localize                         = array();
368
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
369
+        $localize['thousands']            = wpinv_thousands_separator();
370
+        $localize['decimals']             = wpinv_decimal_separator();
371
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
372
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
373
+        $localize['UseTaxes']             = wpinv_use_taxes();
374
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
375
+        $localize['loading']              = __( 'Loading...', 'invoicing' );
376
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
377
+
378
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
379
+
380
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
381
+        wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
382
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
383
+    }
384
+
385
+    public function wpinv_actions() {
386
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
387
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
388
+        }
389
+    }
390
+
391
+    /**
392 392
      * Fires an action after verifying that a user can fire them.
393
-	 *
394
-	 * Note: If the action is on an invoice, subscription etc, esure that the
395
-	 * current user owns the invoice/subscription.
393
+     *
394
+     * Note: If the action is on an invoice, subscription etc, esure that the
395
+     * current user owns the invoice/subscription.
396 396
      */
397 397
     public function maybe_do_authenticated_action() {
398 398
 
399
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
399
+        if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
400 400
 
401
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
402
-			$data = wp_unslash( $_REQUEST );
403
-			if ( is_user_logged_in() ) {
404
-				do_action( "getpaid_authenticated_action_$key", $data );
405
-			}
401
+            $key  = sanitize_key( $_REQUEST['getpaid-action'] );
402
+            $data = wp_unslash( $_REQUEST );
403
+            if ( is_user_logged_in() ) {
404
+                do_action( "getpaid_authenticated_action_$key", $data );
405
+            }
406 406
 
407
-			do_action( "getpaid_unauthenticated_action_$key", $data );
407
+            do_action( "getpaid_unauthenticated_action_$key", $data );
408 408
 
409
-		}
409
+        }
410 410
 
411 411
     }
412 412
 
413
-	public function pre_get_posts( $wp_query ) {
413
+    public function pre_get_posts( $wp_query ) {
414 414
 
415
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
416
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
417
-		}
418
-
419
-		return $wp_query;
420
-	}
415
+        if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
416
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
417
+        }
421 418
 
422
-	/**
423
-	 * Register widgets
424
-	 *
425
-	 */
426
-	public function register_widgets() {
427
-		global $pagenow;
419
+        return $wp_query;
420
+    }
428 421
 
429
-		// Currently, UX Builder does not work particulaly well with SuperDuper.
430
-		// So we disable our widgets when editing a page with UX Builder.
431
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
432
-			return;
433
-		}
434
-
435
-		$block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
436
-
437
-		if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
438
-			// don't initiate in these conditions.
439
-		}else{
440
-
441
-			// Only load allowed widgets.
442
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
443
-			$widgets = apply_filters(
444
-				'getpaid_widget_classes',
445
-				array(
446
-					'WPInv_Checkout_Widget',
447
-					'WPInv_History_Widget',
448
-					'WPInv_Receipt_Widget',
449
-					'WPInv_Subscriptions_Widget',
450
-					'WPInv_Buy_Item_Widget',
451
-					'WPInv_Messages_Widget',
452
-					'WPInv_GetPaid_Widget'
453
-				)
454
-			);
455
-
456
-			// For each widget...
457
-			foreach ( $widgets as $widget ) {
422
+    /**
423
+     * Register widgets
424
+     *
425
+     */
426
+    public function register_widgets() {
427
+        global $pagenow;
458 428
 
459
-				// Abort early if it is excluded for this page.
460
-				if ( in_array( $widget, $exclude ) ) {
461
-					continue;
462
-				}
429
+        // Currently, UX Builder does not work particulaly well with SuperDuper.
430
+        // So we disable our widgets when editing a page with UX Builder.
431
+        if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
432
+            return;
433
+        }
463 434
 
464
-				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
465
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
466
-					register_widget( $widget );
467
-				} else {
468
-					new $widget();
469
-				}
435
+        $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
436
+
437
+        if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
438
+            // don't initiate in these conditions.
439
+        }else{
440
+
441
+            // Only load allowed widgets.
442
+            $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
443
+            $widgets = apply_filters(
444
+                'getpaid_widget_classes',
445
+                array(
446
+                    'WPInv_Checkout_Widget',
447
+                    'WPInv_History_Widget',
448
+                    'WPInv_Receipt_Widget',
449
+                    'WPInv_Subscriptions_Widget',
450
+                    'WPInv_Buy_Item_Widget',
451
+                    'WPInv_Messages_Widget',
452
+                    'WPInv_GetPaid_Widget'
453
+                )
454
+            );
455
+
456
+            // For each widget...
457
+            foreach ( $widgets as $widget ) {
458
+
459
+                // Abort early if it is excluded for this page.
460
+                if ( in_array( $widget, $exclude ) ) {
461
+                    continue;
462
+                }
463
+
464
+                // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
465
+                if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
466
+                    register_widget( $widget );
467
+                } else {
468
+                    new $widget();
469
+                }
470
+
471
+            }
470 472
 
471
-			}
473
+        }
472 474
 
473
-		}
475
+    }
474 476
 
475
-	}
477
+    /**
478
+     * Upgrades the database.
479
+     *
480
+     * @since 2.0.2
481
+     */
482
+    public function maybe_upgrade_database() {
476 483
 
477
-	/**
478
-	 * Upgrades the database.
479
-	 *
480
-	 * @since 2.0.2
481
-	 */
482
-	public function maybe_upgrade_database() {
483
-
484
-		$wpi_version = get_option( 'wpinv_version', 0 );
485
-
486
-		if ( $wpi_version == WPINV_VERSION ) {
487
-			return;
488
-		}
489
-
490
-		$installer = new GetPaid_Installer();
491
-
492
-		if ( empty( $wpi_version ) ) {
493
-			return $installer->upgrade_db( 0 );
494
-		}
495
-
496
-		$upgrades  = array(
497
-			'0.0.5' => '004',
498
-			'1.0.3' => '102',
499
-			'2.0.0' => '118',
500
-			'2.0.8' => '207',
501
-		);
502
-
503
-		foreach ( $upgrades as $key => $method ) {
504
-
505
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
506
-				return $installer->upgrade_db( $method );
507
-			}
508
-
509
-		}
510
-
511
-	}
512
-
513
-	/**
514
-	 * Flushes the permalinks if needed.
515
-	 *
516
-	 * @since 2.0.8
517
-	 */
518
-	public function maybe_flush_permalinks() {
519
-
520
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
521
-
522
-		if ( ! empty( $flush ) ) {
523
-			flush_rewrite_rules();
524
-			delete_option( 'wpinv_flush_permalinks' );
525
-		}
526
-
527
-	}
528
-
529
-	/**
530
-	 * Remove our pages from yoast sitemaps.
531
-	 *
532
-	 * @since 1.0.19
533
-	 * @param int[] $excluded_posts_ids
534
-	 */
535
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
536
-
537
-		// Ensure that we have an array.
538
-		if ( ! is_array( $excluded_posts_ids ) ) {
539
-			$excluded_posts_ids = array();
540
-		}
541
-
542
-		// Prepare our pages.
543
-		$our_pages = array();
544
-
545
-		// Checkout page.
546
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
547
-
548
-		// Success page.
549
-		$our_pages[] = wpinv_get_option( 'success_page', false );
550
-
551
-		// Failure page.
552
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
484
+        $wpi_version = get_option( 'wpinv_version', 0 );
553 485
 
554
-		// History page.
555
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
486
+        if ( $wpi_version == WPINV_VERSION ) {
487
+            return;
488
+        }
556 489
 
557
-		// Subscriptions page.
558
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
490
+        $installer = new GetPaid_Installer();
559 491
 
560
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
492
+        if ( empty( $wpi_version ) ) {
493
+            return $installer->upgrade_db( 0 );
494
+        }
561 495
 
562
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
563
-		return array_unique( $excluded_posts_ids );
496
+        $upgrades  = array(
497
+            '0.0.5' => '004',
498
+            '1.0.3' => '102',
499
+            '2.0.0' => '118',
500
+            '2.0.8' => '207',
501
+        );
564 502
 
565
-	}
503
+        foreach ( $upgrades as $key => $method ) {
566 504
 
567
-	/**
568
-	 * Displays additional footer code.
569
-	 *
570
-	 * @since 2.0.0
571
-	 */
572
-	public function wp_footer() {
573
-		wpinv_get_template( 'frontend-footer.php' );
574
-	}
505
+            if ( version_compare( $wpi_version, $key, '<' ) ) {
506
+                return $installer->upgrade_db( $method );
507
+            }
575 508
 
576
-	/**
577
-	 * Displays additional header code.
578
-	 *
579
-	 * @since 2.0.0
580
-	 */
581
-	public function wp_head() {
582
-		wpinv_get_template( 'frontend-head.php' );
583
-	}
509
+        }
584 510
 
585
-	/**
586
-	 * Custom query vars.
587
-	 *
588
-	 */
589
-	public function custom_query_vars( $vars ) {
511
+    }
512
+
513
+    /**
514
+     * Flushes the permalinks if needed.
515
+     *
516
+     * @since 2.0.8
517
+     */
518
+    public function maybe_flush_permalinks() {
519
+
520
+        $flush = get_option( 'wpinv_flush_permalinks', 0 );
521
+
522
+        if ( ! empty( $flush ) ) {
523
+            flush_rewrite_rules();
524
+            delete_option( 'wpinv_flush_permalinks' );
525
+        }
526
+
527
+    }
528
+
529
+    /**
530
+     * Remove our pages from yoast sitemaps.
531
+     *
532
+     * @since 1.0.19
533
+     * @param int[] $excluded_posts_ids
534
+     */
535
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
536
+
537
+        // Ensure that we have an array.
538
+        if ( ! is_array( $excluded_posts_ids ) ) {
539
+            $excluded_posts_ids = array();
540
+        }
541
+
542
+        // Prepare our pages.
543
+        $our_pages = array();
544
+
545
+        // Checkout page.
546
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
547
+
548
+        // Success page.
549
+        $our_pages[] = wpinv_get_option( 'success_page', false );
550
+
551
+        // Failure page.
552
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
553
+
554
+        // History page.
555
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
556
+
557
+        // Subscriptions page.
558
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
559
+
560
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
561
+
562
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
563
+        return array_unique( $excluded_posts_ids );
564
+
565
+    }
566
+
567
+    /**
568
+     * Displays additional footer code.
569
+     *
570
+     * @since 2.0.0
571
+     */
572
+    public function wp_footer() {
573
+        wpinv_get_template( 'frontend-footer.php' );
574
+    }
575
+
576
+    /**
577
+     * Displays additional header code.
578
+     *
579
+     * @since 2.0.0
580
+     */
581
+    public function wp_head() {
582
+        wpinv_get_template( 'frontend-head.php' );
583
+    }
584
+
585
+    /**
586
+     * Custom query vars.
587
+     *
588
+     */
589
+    public function custom_query_vars( $vars ) {
590 590
         $vars[] = 'getpaid-ipn';
591 591
         return $vars;
592
-	}
592
+    }
593 593
 
594
-	/**
595
-	 * Add rewrite tags and rules.
596
-	 *
597
-	 */
598
-	public function add_rewrite_rule() {
594
+    /**
595
+     * Add rewrite tags and rules.
596
+     *
597
+     */
598
+    public function add_rewrite_rule() {
599 599
         $tag = 'getpaid-ipn';
600 600
         add_rewrite_tag( "%$tag%", '([^&]+)' );
601 601
         add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' );
602
-	}
602
+    }
603 603
 
604
-	/**
605
-	 * Processes non-query string ipns.
606
-	 *
607
-	 */
608
-	public function maybe_process_new_ipn( $query ) {
604
+    /**
605
+     * Processes non-query string ipns.
606
+     *
607
+     */
608
+    public function maybe_process_new_ipn( $query ) {
609 609
 
610 610
         if ( is_admin() || ! $query->is_main_query() ) {
611 611
             return;
612 612
         }
613 613
 
614
-		$gateway = get_query_var( 'getpaid-ipn' );
614
+        $gateway = get_query_var( 'getpaid-ipn' );
615 615
 
616 616
         if ( ! empty( $gateway ) ){
617 617
 
618
-			$gateway = sanitize_text_field( $gateway );
619
-			nocache_headers();
620
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
621
-			do_action( "wpinv_verify_{$gateway}_ipn" );
622
-			exit;
618
+            $gateway = sanitize_text_field( $gateway );
619
+            nocache_headers();
620
+            do_action( 'wpinv_verify_payment_ipn', $gateway );
621
+            do_action( "wpinv_verify_{$gateway}_ipn" );
622
+            exit;
623 623
 
624 624
         }
625 625
 
626
-	}
626
+    }
627 627
 
628 628
 }
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/ayecode-ui-settings.php 1 patch
Indentation   +1186 added lines, -1186 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Bail if we are not in WP.
14 14
  */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -21,243 +21,243 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'AyeCode_UI_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class AyeCode_UI_Settings
28
-	 * @ver 1.0.0
29
-	 * @todo decide how to implement textdomain
30
-	 */
31
-	class AyeCode_UI_Settings {
32
-
33
-		/**
34
-		 * Class version version.
35
-		 *
36
-		 * @var string
37
-		 */
38
-		public $version = '0.1.61';
39
-
40
-		/**
41
-		 * Class textdomain.
42
-		 *
43
-		 * @var string
44
-		 */
45
-		public $textdomain = 'aui';
46
-
47
-		/**
48
-		 * Latest version of Bootstrap at time of publish published.
49
-		 *
50
-		 * @var string
51
-		 */
52
-		public $latest = "4.5.3";
53
-
54
-		/**
55
-		 * Current version of select2 being used.
56
-		 *
57
-		 * @var string
58
-		 */
59
-		public $select2_version = "4.0.11";
60
-
61
-		/**
62
-		 * The title.
63
-		 *
64
-		 * @var string
65
-		 */
66
-		public $name = 'AyeCode UI';
67
-
68
-		/**
69
-		 * The relative url to the assets.
70
-		 *
71
-		 * @var string
72
-		 */
73
-		public $url = '';
74
-
75
-		/**
76
-		 * Holds the settings values.
77
-		 *
78
-		 * @var array
79
-		 */
80
-		private $settings;
81
-
82
-		/**
83
-		 * AyeCode_UI_Settings instance.
84
-		 *
85
-		 * @access private
86
-		 * @since  1.0.0
87
-		 * @var    AyeCode_UI_Settings There can be only one!
88
-		 */
89
-		private static $instance = null;
90
-
91
-		/**
92
-		 * Main AyeCode_UI_Settings Instance.
93
-		 *
94
-		 * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
95
-		 *
96
-		 * @since 1.0.0
97
-		 * @static
98
-		 * @return AyeCode_UI_Settings - Main instance.
99
-		 */
100
-		public static function instance() {
101
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
102
-
103
-				self::$instance = new AyeCode_UI_Settings;
104
-
105
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
106
-
107
-				if ( is_admin() ) {
108
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
109
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
110
-
111
-					// Maybe show example page
112
-					add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
113
-				}
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class AyeCode_UI_Settings
28
+     * @ver 1.0.0
29
+     * @todo decide how to implement textdomain
30
+     */
31
+    class AyeCode_UI_Settings {
32
+
33
+        /**
34
+         * Class version version.
35
+         *
36
+         * @var string
37
+         */
38
+        public $version = '0.1.61';
39
+
40
+        /**
41
+         * Class textdomain.
42
+         *
43
+         * @var string
44
+         */
45
+        public $textdomain = 'aui';
46
+
47
+        /**
48
+         * Latest version of Bootstrap at time of publish published.
49
+         *
50
+         * @var string
51
+         */
52
+        public $latest = "4.5.3";
53
+
54
+        /**
55
+         * Current version of select2 being used.
56
+         *
57
+         * @var string
58
+         */
59
+        public $select2_version = "4.0.11";
60
+
61
+        /**
62
+         * The title.
63
+         *
64
+         * @var string
65
+         */
66
+        public $name = 'AyeCode UI';
67
+
68
+        /**
69
+         * The relative url to the assets.
70
+         *
71
+         * @var string
72
+         */
73
+        public $url = '';
74
+
75
+        /**
76
+         * Holds the settings values.
77
+         *
78
+         * @var array
79
+         */
80
+        private $settings;
81
+
82
+        /**
83
+         * AyeCode_UI_Settings instance.
84
+         *
85
+         * @access private
86
+         * @since  1.0.0
87
+         * @var    AyeCode_UI_Settings There can be only one!
88
+         */
89
+        private static $instance = null;
90
+
91
+        /**
92
+         * Main AyeCode_UI_Settings Instance.
93
+         *
94
+         * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded.
95
+         *
96
+         * @since 1.0.0
97
+         * @static
98
+         * @return AyeCode_UI_Settings - Main instance.
99
+         */
100
+        public static function instance() {
101
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) {
102
+
103
+                self::$instance = new AyeCode_UI_Settings;
104
+
105
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
106
+
107
+                if ( is_admin() ) {
108
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
109
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
110
+
111
+                    // Maybe show example page
112
+                    add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) );
113
+                }
114 114
 
115
-				add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
115
+                add_action( 'customize_register', array( self::$instance, 'customizer_settings' ));
116 116
 
117
-				do_action( 'ayecode_ui_settings_loaded' );
118
-			}
117
+                do_action( 'ayecode_ui_settings_loaded' );
118
+            }
119 119
 
120
-			return self::$instance;
121
-		}
120
+            return self::$instance;
121
+        }
122 122
 
123
-		/**
124
-		 * Setup some constants.
125
-		 */
126
-		public function constants(){
127
-			define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be");
128
-			define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d');
129
-			if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL);
130
-			if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL);
131
-		}
123
+        /**
124
+         * Setup some constants.
125
+         */
126
+        public function constants(){
127
+            define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be");
128
+            define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d');
129
+            if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL);
130
+            if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL);
131
+        }
132 132
 
133
-		/**
134
-		 * Initiate the settings and add the required action hooks.
135
-		 */
136
-		public function init() {
137
-			$this->constants();
138
-			$this->settings = $this->get_settings();
139
-			$this->url = $this->get_url();
140
-
141
-			/**
142
-			 * Maybe load CSS
143
-			 *
144
-			 * We load super early in case there is a theme version that might change the colors
145
-			 */
146
-			if ( $this->settings['css'] ) {
147
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
148
-			}
149
-			if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
150
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
151
-			}
152
-
153
-			// maybe load JS
154
-			if ( $this->settings['js'] ) {
155
-				$priority = $this->is_bs3_compat() ? 100 : 1;
156
-				add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
157
-			}
158
-			if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
159
-				add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
160
-			}
161
-
162
-			// Maybe set the HTML font size
163
-			if ( $this->settings['html_font_size'] ) {
164
-				add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
165
-			}
133
+        /**
134
+         * Initiate the settings and add the required action hooks.
135
+         */
136
+        public function init() {
137
+            $this->constants();
138
+            $this->settings = $this->get_settings();
139
+            $this->url = $this->get_url();
140
+
141
+            /**
142
+             * Maybe load CSS
143
+             *
144
+             * We load super early in case there is a theme version that might change the colors
145
+             */
146
+            if ( $this->settings['css'] ) {
147
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
148
+            }
149
+            if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) {
150
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 );
151
+            }
166 152
 
153
+            // maybe load JS
154
+            if ( $this->settings['js'] ) {
155
+                $priority = $this->is_bs3_compat() ? 100 : 1;
156
+                add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority );
157
+            }
158
+            if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) {
159
+                add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 );
160
+            }
167 161
 
168
-		}
162
+            // Maybe set the HTML font size
163
+            if ( $this->settings['html_font_size'] ) {
164
+                add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 );
165
+            }
169 166
 
170
-		/**
171
-		 * Check if we should load the admin scripts or not.
172
-		 *
173
-		 * @return bool
174
-		 */
175
-		public function load_admin_scripts(){
176
-			$result = true;
177
-
178
-			// check if specifically disabled
179
-			if(!empty($this->settings['disable_admin'])){
180
-				$url_parts = explode("\n",$this->settings['disable_admin']);
181
-				foreach($url_parts as $part){
182
-					if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
183
-						return false; // return early, no point checking further
184
-					}
185
-				}
186
-			}
187 167
 
188
-			return $result;
189
-		}
168
+        }
190 169
 
191
-		/**
192
-		 * Add a html font size to the footer.
193
-		 */
194
-		public function html_font_size(){
195
-			$this->settings = $this->get_settings();
196
-			echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
197
-		}
170
+        /**
171
+         * Check if we should load the admin scripts or not.
172
+         *
173
+         * @return bool
174
+         */
175
+        public function load_admin_scripts(){
176
+            $result = true;
177
+
178
+            // check if specifically disabled
179
+            if(!empty($this->settings['disable_admin'])){
180
+                $url_parts = explode("\n",$this->settings['disable_admin']);
181
+                foreach($url_parts as $part){
182
+                    if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){
183
+                        return false; // return early, no point checking further
184
+                    }
185
+                }
186
+            }
198 187
 
199
-		/**
200
-		 * Check if the current admin screen should load scripts.
201
-		 * 
202
-		 * @return bool
203
-		 */
204
-		public function is_aui_screen(){
205
-			$load = false;
206
-			// check if we should load or not
207
-			if ( is_admin() ) {
208
-				// Only enable on set pages
209
-				$aui_screens = array(
210
-					'page',
211
-					'post',
212
-					'settings_page_ayecode-ui-settings',
213
-					'appearance_page_gutenberg-widgets',
214
-					'widgets'
215
-				);
216
-				$screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
217
-
218
-				$screen = get_current_screen();
188
+            return $result;
189
+        }
190
+
191
+        /**
192
+         * Add a html font size to the footer.
193
+         */
194
+        public function html_font_size(){
195
+            $this->settings = $this->get_settings();
196
+            echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>";
197
+        }
198
+
199
+        /**
200
+         * Check if the current admin screen should load scripts.
201
+         * 
202
+         * @return bool
203
+         */
204
+        public function is_aui_screen(){
205
+            $load = false;
206
+            // check if we should load or not
207
+            if ( is_admin() ) {
208
+                // Only enable on set pages
209
+                $aui_screens = array(
210
+                    'page',
211
+                    'post',
212
+                    'settings_page_ayecode-ui-settings',
213
+                    'appearance_page_gutenberg-widgets',
214
+                    'widgets'
215
+                );
216
+                $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens );
217
+
218
+                $screen = get_current_screen();
219 219
 
220 220
 //				echo '###'.$screen->id;
221 221
 
222
-				// check if we are on a AUI screen
223
-				if ( $screen && in_array( $screen->id, $screen_ids ) ) {
224
-					$load = true;
225
-				}
222
+                // check if we are on a AUI screen
223
+                if ( $screen && in_array( $screen->id, $screen_ids ) ) {
224
+                    $load = true;
225
+                }
226 226
 
227
-				//load for widget previews in WP 5.8
228
-				if( !empty($_REQUEST['legacy-widget-preview'])){
229
-					$load = true;
230
-				}
231
-			}
227
+                //load for widget previews in WP 5.8
228
+                if( !empty($_REQUEST['legacy-widget-preview'])){
229
+                    $load = true;
230
+                }
231
+            }
232 232
 
233
-			return apply_filters( 'aui_load_on_admin' , $load );
234
-		}
233
+            return apply_filters( 'aui_load_on_admin' , $load );
234
+        }
235 235
 
236
-		/**
237
-		 * Adds the styles.
238
-		 */
239
-		public function enqueue_style() {
236
+        /**
237
+         * Adds the styles.
238
+         */
239
+        public function enqueue_style() {
240 240
 
241
-			if( is_admin() && !$this->is_aui_screen()){
242
-				// don't add wp-admin scripts if not requested to
243
-			}else{
244
-				$css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
241
+            if( is_admin() && !$this->is_aui_screen()){
242
+                // don't add wp-admin scripts if not requested to
243
+            }else{
244
+                $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend';
245 245
 
246
-				$rtl = is_rtl() ? '-rtl' : '';
246
+                $rtl = is_rtl() ? '-rtl' : '';
247 247
 
248
-				if($this->settings[$css_setting]){
249
-					$compatibility = $this->settings[$css_setting]=='core' ? false : true;
250
-					$url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css';
251
-					wp_register_style( 'ayecode-ui', $url, array(), $this->latest );
252
-					wp_enqueue_style( 'ayecode-ui' );
248
+                if($this->settings[$css_setting]){
249
+                    $compatibility = $this->settings[$css_setting]=='core' ? false : true;
250
+                    $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css';
251
+                    wp_register_style( 'ayecode-ui', $url, array(), $this->latest );
252
+                    wp_enqueue_style( 'ayecode-ui' );
253 253
 
254
-					// flatpickr
255
-					wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest );
254
+                    // flatpickr
255
+                    wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest );
256 256
 
257 257
 
258
-					// fix some wp-admin issues
259
-					if(is_admin()){
260
-						$custom_css = "
258
+                    // fix some wp-admin issues
259
+                    if(is_admin()){
260
+                        $custom_css = "
261 261
                 body{
262 262
                     background-color: #f1f1f1;
263 263
                     font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif;
@@ -299,35 +299,35 @@  discard block
 block discarded – undo
299 299
 				}
300 300
                 ";
301 301
 
302
-						// @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
303
-						$custom_css .= "
302
+                        // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377
303
+                        $custom_css .= "
304 304
 						.edit-post-sidebar input[type=color].components-text-control__input{
305 305
 						    padding: 0;
306 306
 						}
307 307
 					";
308
-						wp_add_inline_style( 'ayecode-ui', $custom_css );
309
-					}
308
+                        wp_add_inline_style( 'ayecode-ui', $custom_css );
309
+                    }
310 310
 
311
-					// custom changes
312
-					wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
311
+                    // custom changes
312
+                    wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) );
313 313
 
314
-				}
315
-			}
314
+                }
315
+            }
316 316
 
317 317
 
318
-		}
318
+        }
319 319
 
320
-		/**
321
-		 * Get inline script used if bootstrap enqueued
322
-		 *
323
-		 * If this remains small then its best to use this than to add another JS file.
324
-		 */
325
-		public function inline_script() {
326
-			// Flatpickr calendar locale
327
-			$flatpickr_locale = self::flatpickr_locale();
328
-
329
-			ob_start();
330
-			?>
320
+        /**
321
+         * Get inline script used if bootstrap enqueued
322
+         *
323
+         * If this remains small then its best to use this than to add another JS file.
324
+         */
325
+        public function inline_script() {
326
+            // Flatpickr calendar locale
327
+            $flatpickr_locale = self::flatpickr_locale();
328
+
329
+            ob_start();
330
+            ?>
331 331
 			<script>
332 332
 				/**
333 333
 				 * An AUI bootstrap adaptation of GreedyNav.js ( by Luke Jackson ).
@@ -1016,29 +1016,29 @@  discard block
 block discarded – undo
1016 1016
 				});
1017 1017
 			</script>
1018 1018
 			<?php
1019
-			$output = ob_get_clean();
1019
+            $output = ob_get_clean();
1020 1020
 
1021 1021
 
1022 1022
 
1023
-			/*
1023
+            /*
1024 1024
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1025 1025
 			 */
1026
-			return str_replace( array(
1027
-				'<script>',
1028
-				'</script>'
1029
-			), '', self::minify_js($output) );
1030
-		}
1026
+            return str_replace( array(
1027
+                '<script>',
1028
+                '</script>'
1029
+            ), '', self::minify_js($output) );
1030
+        }
1031 1031
 
1032 1032
 
1033
-		/**
1034
-		 * JS to help with conflict issues with other plugins and themes using bootstrap v3.
1035
-		 *
1036
-		 * @TODO we may need this when other conflicts arrise.
1037
-		 * @return mixed
1038
-		 */
1039
-		public static function bs3_compat_js() {
1040
-			ob_start();
1041
-			?>
1033
+        /**
1034
+         * JS to help with conflict issues with other plugins and themes using bootstrap v3.
1035
+         *
1036
+         * @TODO we may need this when other conflicts arrise.
1037
+         * @return mixed
1038
+         */
1039
+        public static function bs3_compat_js() {
1040
+            ob_start();
1041
+            ?>
1042 1042
 			<script>
1043 1043
 				<?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?>
1044 1044
 				/* With Avada builder */
@@ -1046,20 +1046,20 @@  discard block
 block discarded – undo
1046 1046
 				<?php } ?>
1047 1047
 			</script>
1048 1048
 			<?php
1049
-			return str_replace( array(
1050
-				'<script>',
1051
-				'</script>'
1052
-			), '', ob_get_clean());
1053
-		}
1049
+            return str_replace( array(
1050
+                '<script>',
1051
+                '</script>'
1052
+            ), '', ob_get_clean());
1053
+        }
1054 1054
 
1055
-		/**
1056
-		 * Get inline script used if bootstrap file browser enqueued.
1057
-		 *
1058
-		 * If this remains small then its best to use this than to add another JS file.
1059
-		 */
1060
-		public function inline_script_file_browser(){
1061
-			ob_start();
1062
-			?>
1055
+        /**
1056
+         * Get inline script used if bootstrap file browser enqueued.
1057
+         *
1058
+         * If this remains small then its best to use this than to add another JS file.
1059
+         */
1060
+        public function inline_script_file_browser(){
1061
+            ob_start();
1062
+            ?>
1063 1063
 			<script>
1064 1064
 				// run on doc ready
1065 1065
 				jQuery(document).ready(function () {
@@ -1067,192 +1067,192 @@  discard block
 block discarded – undo
1067 1067
 				});
1068 1068
 			</script>
1069 1069
 			<?php
1070
-			$output = ob_get_clean();
1070
+            $output = ob_get_clean();
1071 1071
 
1072
-			/*
1072
+            /*
1073 1073
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1074 1074
 			 */
1075
-			return str_replace( array(
1076
-				'<script>',
1077
-				'</script>'
1078
-			), '', $output );
1079
-		}
1075
+            return str_replace( array(
1076
+                '<script>',
1077
+                '</script>'
1078
+            ), '', $output );
1079
+        }
1080 1080
 
1081
-		/**
1082
-		 * Adds the Font Awesome JS.
1083
-		 */
1084
-		public function enqueue_scripts() {
1085
-
1086
-			if( is_admin() && !$this->is_aui_screen()){
1087
-				// don't add wp-admin scripts if not requested to
1088
-			}else {
1089
-
1090
-				$js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
1091
-
1092
-				// select2
1093
-				wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
1094
-
1095
-				// flatpickr
1096
-				wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest );
1097
-
1098
-				// Bootstrap file browser
1099
-				wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
1100
-				wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
1101
-
1102
-				$load_inline = false;
1103
-
1104
-				if ( $this->settings[ $js_setting ] == 'core-popper' ) {
1105
-					// Bootstrap bundle
1106
-					$url = $this->url . 'assets/js/bootstrap.bundle.min.js';
1107
-					wp_register_script( 'bootstrap-js-bundle', $url, array(
1108
-						'select2',
1109
-						'jquery'
1110
-					), $this->latest, $this->is_bs3_compat() );
1111
-					// if in admin then add to footer for compatibility.
1112
-					is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
1113
-					$script = $this->inline_script();
1114
-					wp_add_inline_script( 'bootstrap-js-bundle', $script );
1115
-				} elseif ( $this->settings[ $js_setting ] == 'popper' ) {
1116
-					$url = $this->url . 'assets/js/popper.min.js';
1117
-					wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest );
1118
-					wp_enqueue_script( 'bootstrap-js-popper' );
1119
-					$load_inline = true;
1120
-				} else {
1121
-					$load_inline = true;
1122
-				}
1081
+        /**
1082
+         * Adds the Font Awesome JS.
1083
+         */
1084
+        public function enqueue_scripts() {
1085
+
1086
+            if( is_admin() && !$this->is_aui_screen()){
1087
+                // don't add wp-admin scripts if not requested to
1088
+            }else {
1089
+
1090
+                $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend';
1091
+
1092
+                // select2
1093
+                wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version );
1094
+
1095
+                // flatpickr
1096
+                wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest );
1097
+
1098
+                // Bootstrap file browser
1099
+                wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version );
1100
+                wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() );
1101
+
1102
+                $load_inline = false;
1103
+
1104
+                if ( $this->settings[ $js_setting ] == 'core-popper' ) {
1105
+                    // Bootstrap bundle
1106
+                    $url = $this->url . 'assets/js/bootstrap.bundle.min.js';
1107
+                    wp_register_script( 'bootstrap-js-bundle', $url, array(
1108
+                        'select2',
1109
+                        'jquery'
1110
+                    ), $this->latest, $this->is_bs3_compat() );
1111
+                    // if in admin then add to footer for compatibility.
1112
+                    is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' );
1113
+                    $script = $this->inline_script();
1114
+                    wp_add_inline_script( 'bootstrap-js-bundle', $script );
1115
+                } elseif ( $this->settings[ $js_setting ] == 'popper' ) {
1116
+                    $url = $this->url . 'assets/js/popper.min.js';
1117
+                    wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest );
1118
+                    wp_enqueue_script( 'bootstrap-js-popper' );
1119
+                    $load_inline = true;
1120
+                } else {
1121
+                    $load_inline = true;
1122
+                }
1123 1123
 
1124
-				// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
1125
-				if ( $load_inline ) {
1126
-					wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
1127
-					wp_enqueue_script( 'bootstrap-dummy' );
1128
-					$script = $this->inline_script();
1129
-					wp_add_inline_script( 'bootstrap-dummy', $script );
1130
-				}
1131
-			}
1124
+                // Load needed inline scripts by faking the loading of a script if the main script is not being loaded
1125
+                if ( $load_inline ) {
1126
+                    wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) );
1127
+                    wp_enqueue_script( 'bootstrap-dummy' );
1128
+                    $script = $this->inline_script();
1129
+                    wp_add_inline_script( 'bootstrap-dummy', $script );
1130
+                }
1131
+            }
1132 1132
 
1133
-		}
1133
+        }
1134 1134
 
1135
-		/**
1136
-		 * Enqueue flatpickr if called.
1137
-		 */
1138
-		public function enqueue_flatpickr(){
1139
-			wp_enqueue_style( 'flatpickr' );
1140
-			wp_enqueue_script( 'flatpickr' );
1141
-		}
1135
+        /**
1136
+         * Enqueue flatpickr if called.
1137
+         */
1138
+        public function enqueue_flatpickr(){
1139
+            wp_enqueue_style( 'flatpickr' );
1140
+            wp_enqueue_script( 'flatpickr' );
1141
+        }
1142 1142
 
1143
-		/**
1144
-		 * Get the url path to the current folder.
1145
-		 *
1146
-		 * @return string
1147
-		 */
1148
-		public function get_url() {
1143
+        /**
1144
+         * Get the url path to the current folder.
1145
+         *
1146
+         * @return string
1147
+         */
1148
+        public function get_url() {
1149 1149
 
1150
-			$url = '';
1151
-			// check if we are inside a plugin
1152
-			$file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
1150
+            $url = '';
1151
+            // check if we are inside a plugin
1152
+            $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) );
1153 1153
 
1154
-			// add check in-case user has changed wp-content dir name.
1155
-			$wp_content_folder_name = basename(WP_CONTENT_DIR);
1156
-			$dir_parts = explode("/$wp_content_folder_name/",$file_dir);
1157
-			$url_parts = explode("/$wp_content_folder_name/",plugins_url());
1154
+            // add check in-case user has changed wp-content dir name.
1155
+            $wp_content_folder_name = basename(WP_CONTENT_DIR);
1156
+            $dir_parts = explode("/$wp_content_folder_name/",$file_dir);
1157
+            $url_parts = explode("/$wp_content_folder_name/",plugins_url());
1158 1158
 
1159
-			if(!empty($url_parts[0]) && !empty($dir_parts[1])){
1160
-				$url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
1161
-			}
1159
+            if(!empty($url_parts[0]) && !empty($dir_parts[1])){
1160
+                $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] );
1161
+            }
1162 1162
 
1163
-			return $url;
1164
-		}
1163
+            return $url;
1164
+        }
1165 1165
 
1166
-		/**
1167
-		 * Register the database settings with WordPress.
1168
-		 */
1169
-		public function register_settings() {
1170
-			register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
1171
-		}
1166
+        /**
1167
+         * Register the database settings with WordPress.
1168
+         */
1169
+        public function register_settings() {
1170
+            register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' );
1171
+        }
1172 1172
 
1173
-		/**
1174
-		 * Add the WordPress settings menu item.
1175
-		 * @since 1.0.10 Calling function name direct will fail theme check so we don't.
1176
-		 */
1177
-		public function menu_item() {
1178
-			$menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
1179
-			call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
1180
-				$this,
1181
-				'settings_page'
1182
-			) );
1183
-		}
1173
+        /**
1174
+         * Add the WordPress settings menu item.
1175
+         * @since 1.0.10 Calling function name direct will fail theme check so we don't.
1176
+         */
1177
+        public function menu_item() {
1178
+            $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme
1179
+            call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array(
1180
+                $this,
1181
+                'settings_page'
1182
+            ) );
1183
+        }
1184 1184
 
1185
-		/**
1186
-		 * Get a list of themes and their default JS settings.
1187
-		 *
1188
-		 * @return array
1189
-		 */
1190
-		public function theme_js_settings(){
1191
-			return array(
1192
-				'ayetheme' => 'popper',
1193
-				'listimia' => 'required',
1194
-				'listimia_backend' => 'core-popper',
1195
-				//'avada'    => 'required', // removed as we now add compatibility
1196
-			);
1197
-		}
1185
+        /**
1186
+         * Get a list of themes and their default JS settings.
1187
+         *
1188
+         * @return array
1189
+         */
1190
+        public function theme_js_settings(){
1191
+            return array(
1192
+                'ayetheme' => 'popper',
1193
+                'listimia' => 'required',
1194
+                'listimia_backend' => 'core-popper',
1195
+                //'avada'    => 'required', // removed as we now add compatibility
1196
+            );
1197
+        }
1198 1198
 
1199
-		/**
1200
-		 * Get the current Font Awesome output settings.
1201
-		 *
1202
-		 * @return array The array of settings.
1203
-		 */
1204
-		public function get_settings() {
1205
-
1206
-			$db_settings = get_option( 'ayecode-ui-settings' );
1207
-			$js_default = 'core-popper';
1208
-			$js_default_backend = $js_default;
1209
-
1210
-			// maybe set defaults (if no settings set)
1211
-			if(empty($db_settings)){
1212
-				$active_theme = strtolower( get_template() ); // active parent theme.
1213
-				$theme_js_settings = self::theme_js_settings();
1214
-				if(isset($theme_js_settings[$active_theme])){
1215
-					$js_default = $theme_js_settings[$active_theme];
1216
-					$js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
1217
-				}
1218
-			}
1219
-
1220
-			$defaults = array(
1221
-				'css'       => 'compatibility', // core, compatibility
1222
-				'js'        => $js_default, // js to load, core-popper, popper
1223
-				'html_font_size'        => '16', // js to load, core-popper, popper
1224
-				'css_backend'       => 'compatibility', // core, compatibility
1225
-				'js_backend'        => $js_default_backend, // js to load, core-popper, popper
1226
-				'disable_admin'     =>  '', // URL snippets to disable loading on admin
1227
-			);
1228
-
1229
-			$settings = wp_parse_args( $db_settings, $defaults );
1230
-
1231
-			/**
1232
-			 * Filter the Bootstrap settings.
1233
-			 *
1234
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
1235
-			 */
1236
-			return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
1237
-		}
1199
+        /**
1200
+         * Get the current Font Awesome output settings.
1201
+         *
1202
+         * @return array The array of settings.
1203
+         */
1204
+        public function get_settings() {
1205
+
1206
+            $db_settings = get_option( 'ayecode-ui-settings' );
1207
+            $js_default = 'core-popper';
1208
+            $js_default_backend = $js_default;
1209
+
1210
+            // maybe set defaults (if no settings set)
1211
+            if(empty($db_settings)){
1212
+                $active_theme = strtolower( get_template() ); // active parent theme.
1213
+                $theme_js_settings = self::theme_js_settings();
1214
+                if(isset($theme_js_settings[$active_theme])){
1215
+                    $js_default = $theme_js_settings[$active_theme];
1216
+                    $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default;
1217
+                }
1218
+            }
1219
+
1220
+            $defaults = array(
1221
+                'css'       => 'compatibility', // core, compatibility
1222
+                'js'        => $js_default, // js to load, core-popper, popper
1223
+                'html_font_size'        => '16', // js to load, core-popper, popper
1224
+                'css_backend'       => 'compatibility', // core, compatibility
1225
+                'js_backend'        => $js_default_backend, // js to load, core-popper, popper
1226
+                'disable_admin'     =>  '', // URL snippets to disable loading on admin
1227
+            );
1228
+
1229
+            $settings = wp_parse_args( $db_settings, $defaults );
1230
+
1231
+            /**
1232
+             * Filter the Bootstrap settings.
1233
+             *
1234
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
1235
+             */
1236
+            return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults );
1237
+        }
1238 1238
 
1239 1239
 
1240
-		/**
1241
-		 * The settings page html output.
1242
-		 */
1243
-		public function settings_page() {
1244
-			if ( ! current_user_can( 'manage_options' ) ) {
1245
-				wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) );
1246
-			}
1247
-			?>
1240
+        /**
1241
+         * The settings page html output.
1242
+         */
1243
+        public function settings_page() {
1244
+            if ( ! current_user_can( 'manage_options' ) ) {
1245
+                wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) );
1246
+            }
1247
+            ?>
1248 1248
 			<div class="wrap">
1249 1249
 				<h1><?php echo $this->name; ?></h1>
1250 1250
 				<p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p>
1251 1251
 				<form method="post" action="options.php">
1252 1252
 					<?php
1253
-					settings_fields( 'ayecode-ui-settings' );
1254
-					do_settings_sections( 'ayecode-ui-settings' );
1255
-					?>
1253
+                    settings_fields( 'ayecode-ui-settings' );
1254
+                    do_settings_sections( 'ayecode-ui-settings' );
1255
+                    ?>
1256 1256
 
1257 1257
 					<h2><?php _e( 'Frontend', 'aui' ); ?></h2>
1258 1258
 					<table class="form-table wpbs-table-settings">
@@ -1332,60 +1332,60 @@  discard block
 block discarded – undo
1332 1332
 					</table>
1333 1333
 
1334 1334
 					<?php
1335
-					submit_button();
1336
-					?>
1335
+                    submit_button();
1336
+                    ?>
1337 1337
 				</form>
1338 1338
 
1339 1339
 				<div id="wpbs-version"><?php echo $this->version; ?></div>
1340 1340
 			</div>
1341 1341
 
1342 1342
 			<?php
1343
-		}
1343
+        }
1344 1344
 
1345
-		public function customizer_settings($wp_customize){
1346
-			$wp_customize->add_section('aui_settings', array(
1347
-				'title'    => __('AyeCode UI','aui'),
1348
-				'priority' => 120,
1349
-			));
1350
-
1351
-			//  =============================
1352
-			//  = Color Picker              =
1353
-			//  =============================
1354
-			$wp_customize->add_setting('aui_options[color_primary]', array(
1355
-				'default'           => AUI_PRIMARY_COLOR,
1356
-				'sanitize_callback' => 'sanitize_hex_color',
1357
-				'capability'        => 'edit_theme_options',
1358
-				'type'              => 'option',
1359
-				'transport'         => 'refresh',
1360
-			));
1361
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1362
-				'label'    => __('Primary Color','aui'),
1363
-				'section'  => 'aui_settings',
1364
-				'settings' => 'aui_options[color_primary]',
1365
-			)));
1366
-
1367
-			$wp_customize->add_setting('aui_options[color_secondary]', array(
1368
-				'default'           => '#6c757d',
1369
-				'sanitize_callback' => 'sanitize_hex_color',
1370
-				'capability'        => 'edit_theme_options',
1371
-				'type'              => 'option',
1372
-				'transport'         => 'refresh',
1373
-			));
1374
-			$wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1375
-				'label'    => __('Secondary Color','aui'),
1376
-				'section'  => 'aui_settings',
1377
-				'settings' => 'aui_options[color_secondary]',
1378
-			)));
1379
-		}
1345
+        public function customizer_settings($wp_customize){
1346
+            $wp_customize->add_section('aui_settings', array(
1347
+                'title'    => __('AyeCode UI','aui'),
1348
+                'priority' => 120,
1349
+            ));
1350
+
1351
+            //  =============================
1352
+            //  = Color Picker              =
1353
+            //  =============================
1354
+            $wp_customize->add_setting('aui_options[color_primary]', array(
1355
+                'default'           => AUI_PRIMARY_COLOR,
1356
+                'sanitize_callback' => 'sanitize_hex_color',
1357
+                'capability'        => 'edit_theme_options',
1358
+                'type'              => 'option',
1359
+                'transport'         => 'refresh',
1360
+            ));
1361
+            $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array(
1362
+                'label'    => __('Primary Color','aui'),
1363
+                'section'  => 'aui_settings',
1364
+                'settings' => 'aui_options[color_primary]',
1365
+            )));
1366
+
1367
+            $wp_customize->add_setting('aui_options[color_secondary]', array(
1368
+                'default'           => '#6c757d',
1369
+                'sanitize_callback' => 'sanitize_hex_color',
1370
+                'capability'        => 'edit_theme_options',
1371
+                'type'              => 'option',
1372
+                'transport'         => 'refresh',
1373
+            ));
1374
+            $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array(
1375
+                'label'    => __('Secondary Color','aui'),
1376
+                'section'  => 'aui_settings',
1377
+                'settings' => 'aui_options[color_secondary]',
1378
+            )));
1379
+        }
1380 1380
 
1381
-		/**
1382
-		 * CSS to help with conflict issues with other plugins and themes using bootstrap v3.
1383
-		 *
1384
-		 * @return mixed
1385
-		 */
1386
-		public static function bs3_compat_css() {
1387
-			ob_start();
1388
-			?>
1381
+        /**
1382
+         * CSS to help with conflict issues with other plugins and themes using bootstrap v3.
1383
+         *
1384
+         * @return mixed
1385
+         */
1386
+        public static function bs3_compat_css() {
1387
+            ob_start();
1388
+            ?>
1389 1389
 			<style>
1390 1390
 			/* Bootstrap 3 compatibility */
1391 1391
 			body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;}
@@ -1411,579 +1411,579 @@  discard block
 block discarded – undo
1411 1411
 			<?php } ?>
1412 1412
 			</style>
1413 1413
 			<?php
1414
-			return str_replace( array(
1415
-				'<style>',
1416
-				'</style>'
1417
-			), '', self::minify_css( ob_get_clean() ) );
1418
-		}
1414
+            return str_replace( array(
1415
+                '<style>',
1416
+                '</style>'
1417
+            ), '', self::minify_css( ob_get_clean() ) );
1418
+        }
1419 1419
 
1420 1420
 
1421
-		public static function custom_css($compatibility = true) {
1422
-			$settings = get_option('aui_options');
1421
+        public static function custom_css($compatibility = true) {
1422
+            $settings = get_option('aui_options');
1423 1423
 
1424
-			ob_start();
1424
+            ob_start();
1425 1425
 
1426
-			$primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR;
1427
-			$secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR;
1428
-				//AUI_PRIMARY_COLOR_ORIGINAL
1429
-			?>
1426
+            $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR;
1427
+            $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR;
1428
+                //AUI_PRIMARY_COLOR_ORIGINAL
1429
+            ?>
1430 1430
 			<style>
1431 1431
 				<?php
1432 1432
 
1433
-					// BS v3 compat
1434
-					if( self::is_bs3_compat() ){
1435
-					    echo self::bs3_compat_css();
1436
-					}
1433
+                    // BS v3 compat
1434
+                    if( self::is_bs3_compat() ){
1435
+                        echo self::bs3_compat_css();
1436
+                    }
1437 1437
 
1438
-					if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){
1439
-						echo self::css_primary($primary_color,$compatibility);
1440
-					}
1438
+                    if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){
1439
+                        echo self::css_primary($primary_color,$compatibility);
1440
+                    }
1441 1441
 
1442
-					if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){
1443
-						echo self::css_secondary($settings['color_secondary'],$compatibility);
1444
-					}
1442
+                    if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){
1443
+                        echo self::css_secondary($settings['color_secondary'],$compatibility);
1444
+                    }
1445 1445
 
1446
-					// Set admin bar z-index lower when modal is open.
1447
-					echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1446
+                    // Set admin bar z-index lower when modal is open.
1447
+                    echo ' body.modal-open #wpadminbar{z-index:999}.embed-responsive-16by9 .fluid-width-video-wrapper{padding:0 !important;position:initial}';
1448 1448
                 ?>
1449 1449
 			</style>
1450 1450
 			<?php
1451 1451
 
1452 1452
 
1453
-			/*
1453
+            /*
1454 1454
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1455 1455
 			 */
1456
-			return str_replace( array(
1457
-				'<style>',
1458
-				'</style>'
1459
-			), '', self::minify_css( ob_get_clean() ) );
1460
-		}
1456
+            return str_replace( array(
1457
+                '<style>',
1458
+                '</style>'
1459
+            ), '', self::minify_css( ob_get_clean() ) );
1460
+        }
1461 1461
 
1462
-		/**
1463
-		 * Check if we should add booststrap 3 compatibility changes.
1464
-		 *
1465
-		 * @return bool
1466
-		 */
1467
-		public static function is_bs3_compat(){
1468
-			return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1469
-		}
1462
+        /**
1463
+         * Check if we should add booststrap 3 compatibility changes.
1464
+         *
1465
+         * @return bool
1466
+         */
1467
+        public static function is_bs3_compat(){
1468
+            return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION');
1469
+        }
1470 1470
 
1471
-		public static function css_primary($color_code,$compatibility){;
1472
-			$color_code = sanitize_hex_color($color_code);
1473
-			if(!$color_code){return '';}
1474
-			/**
1475
-			 * c = color, b = background color, o = border-color, f = fill
1476
-			 */
1477
-			$selectors = array(
1478
-				'a' => array('c'),
1479
-				'.btn-primary' => array('b','o'),
1480
-				'.btn-primary.disabled' => array('b','o'),
1481
-				'.btn-primary:disabled' => array('b','o'),
1482
-				'.btn-outline-primary' => array('c','o'),
1483
-				'.btn-outline-primary:hover' => array('b','o'),
1484
-				'.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1485
-				'.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1486
-				'.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1487
-				'.btn-link' => array('c'),
1488
-				'.dropdown-item.active' => array('b'),
1489
-				'.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1490
-				'.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1471
+        public static function css_primary($color_code,$compatibility){;
1472
+            $color_code = sanitize_hex_color($color_code);
1473
+            if(!$color_code){return '';}
1474
+            /**
1475
+             * c = color, b = background color, o = border-color, f = fill
1476
+             */
1477
+            $selectors = array(
1478
+                'a' => array('c'),
1479
+                '.btn-primary' => array('b','o'),
1480
+                '.btn-primary.disabled' => array('b','o'),
1481
+                '.btn-primary:disabled' => array('b','o'),
1482
+                '.btn-outline-primary' => array('c','o'),
1483
+                '.btn-outline-primary:hover' => array('b','o'),
1484
+                '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'),
1485
+                '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'),
1486
+                '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'),
1487
+                '.btn-link' => array('c'),
1488
+                '.dropdown-item.active' => array('b'),
1489
+                '.custom-control-input:checked~.custom-control-label::before' => array('b','o'),
1490
+                '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'),
1491 1491
 //				'.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules...
1492 1492
 //				'.custom-range::-moz-range-thumb' => array('b'),
1493 1493
 //				'.custom-range::-ms-thumb' => array('b'),
1494
-				'.nav-pills .nav-link.active' => array('b'),
1495
-				'.nav-pills .show>.nav-link' => array('b'),
1496
-				'.page-link' => array('c'),
1497
-				'.page-item.active .page-link' => array('b','o'),
1498
-				'.badge-primary' => array('b'),
1499
-				'.alert-primary' => array('b','o'),
1500
-				'.progress-bar' => array('b'),
1501
-				'.list-group-item.active' => array('b','o'),
1502
-				'.bg-primary' => array('b','f'),
1503
-				'.btn-link.btn-primary' => array('c'),
1504
-				'.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1505
-			);
1506
-
1507
-			$important_selectors = array(
1508
-				'.bg-primary' => array('b','f'),
1509
-				'.border-primary' => array('o'),
1510
-				'.text-primary' => array('c'),
1511
-			);
1512
-
1513
-			$color = array();
1514
-			$color_i = array();
1515
-			$background = array();
1516
-			$background_i = array();
1517
-			$border = array();
1518
-			$border_i = array();
1519
-			$fill = array();
1520
-			$fill_i = array();
1521
-
1522
-			$output = '';
1523
-
1524
-			// build rules into each type
1525
-			foreach($selectors as $selector => $types){
1526
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1527
-				$types = array_combine($types,$types);
1528
-				if(isset($types['c'])){$color[] = $selector;}
1529
-				if(isset($types['b'])){$background[] = $selector;}
1530
-				if(isset($types['o'])){$border[] = $selector;}
1531
-				if(isset($types['f'])){$fill[] = $selector;}
1532
-			}
1533
-
1534
-			// build rules into each type
1535
-			foreach($important_selectors as $selector => $types){
1536
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1537
-				$types = array_combine($types,$types);
1538
-				if(isset($types['c'])){$color_i[] = $selector;}
1539
-				if(isset($types['b'])){$background_i[] = $selector;}
1540
-				if(isset($types['o'])){$border_i[] = $selector;}
1541
-				if(isset($types['f'])){$fill_i[] = $selector;}
1542
-			}
1543
-
1544
-			// add any color rules
1545
-			if(!empty($color)){
1546
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1547
-			}
1548
-			if(!empty($color_i)){
1549
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1550
-			}
1551
-
1552
-			// add any background color rules
1553
-			if(!empty($background)){
1554
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1555
-			}
1556
-			if(!empty($background_i)){
1557
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1558
-			}
1559
-
1560
-			// add any border color rules
1561
-			if(!empty($border)){
1562
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1563
-			}
1564
-			if(!empty($border_i)){
1565
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1566
-			}
1567
-
1568
-			// add any fill color rules
1569
-			if(!empty($fill)){
1570
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1571
-			}
1572
-			if(!empty($fill_i)){
1573
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1574
-			}
1575
-
1576
-
1577
-			$prefix = $compatibility ? ".bsui " : "";
1578
-
1579
-			// darken
1580
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1581
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1582
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1583
-
1584
-			// lighten
1585
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1586
-
1587
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1588
-			$op_25 = $color_code."40"; // 25% opacity
1589
-
1590
-
1591
-			// button states
1592
-			$output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1593
-			$output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1594
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1595
-			$output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1596
-
1597
-
1598
-			// dropdown's
1599
-			$output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1600
-
1601
-
1602
-			// input states
1603
-			$output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
1604
-
1605
-			// page link
1606
-			$output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1607
-
1608
-			return $output;
1609
-		}
1494
+                '.nav-pills .nav-link.active' => array('b'),
1495
+                '.nav-pills .show>.nav-link' => array('b'),
1496
+                '.page-link' => array('c'),
1497
+                '.page-item.active .page-link' => array('b','o'),
1498
+                '.badge-primary' => array('b'),
1499
+                '.alert-primary' => array('b','o'),
1500
+                '.progress-bar' => array('b'),
1501
+                '.list-group-item.active' => array('b','o'),
1502
+                '.bg-primary' => array('b','f'),
1503
+                '.btn-link.btn-primary' => array('c'),
1504
+                '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'),
1505
+            );
1506
+
1507
+            $important_selectors = array(
1508
+                '.bg-primary' => array('b','f'),
1509
+                '.border-primary' => array('o'),
1510
+                '.text-primary' => array('c'),
1511
+            );
1512
+
1513
+            $color = array();
1514
+            $color_i = array();
1515
+            $background = array();
1516
+            $background_i = array();
1517
+            $border = array();
1518
+            $border_i = array();
1519
+            $fill = array();
1520
+            $fill_i = array();
1521
+
1522
+            $output = '';
1523
+
1524
+            // build rules into each type
1525
+            foreach($selectors as $selector => $types){
1526
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1527
+                $types = array_combine($types,$types);
1528
+                if(isset($types['c'])){$color[] = $selector;}
1529
+                if(isset($types['b'])){$background[] = $selector;}
1530
+                if(isset($types['o'])){$border[] = $selector;}
1531
+                if(isset($types['f'])){$fill[] = $selector;}
1532
+            }
1610 1533
 
1611
-		public static function css_secondary($color_code,$compatibility){;
1612
-			$color_code = sanitize_hex_color($color_code);
1613
-			if(!$color_code){return '';}
1614
-			/**
1615
-			 * c = color, b = background color, o = border-color, f = fill
1616
-			 */
1617
-			$selectors = array(
1618
-				'.btn-secondary' => array('b','o'),
1619
-				'.btn-secondary.disabled' => array('b','o'),
1620
-				'.btn-secondary:disabled' => array('b','o'),
1621
-				'.btn-outline-secondary' => array('c','o'),
1622
-				'.btn-outline-secondary:hover' => array('b','o'),
1623
-				'.btn-outline-secondary.disabled' => array('c'),
1624
-				'.btn-outline-secondary:disabled' => array('c'),
1625
-				'.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
1626
-				'.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
1627
-				'.btn-outline-secondary.dropdown-toggle' => array('b','o'),
1628
-				'.badge-secondary' => array('b'),
1629
-				'.alert-secondary' => array('b','o'),
1630
-				'.btn-link.btn-secondary' => array('c'),
1631
-			);
1632
-
1633
-			$important_selectors = array(
1634
-				'.bg-secondary' => array('b','f'),
1635
-				'.border-secondary' => array('o'),
1636
-				'.text-secondary' => array('c'),
1637
-			);
1638
-
1639
-			$color = array();
1640
-			$color_i = array();
1641
-			$background = array();
1642
-			$background_i = array();
1643
-			$border = array();
1644
-			$border_i = array();
1645
-			$fill = array();
1646
-			$fill_i = array();
1647
-
1648
-			$output = '';
1649
-
1650
-			// build rules into each type
1651
-			foreach($selectors as $selector => $types){
1652
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1653
-				$types = array_combine($types,$types);
1654
-				if(isset($types['c'])){$color[] = $selector;}
1655
-				if(isset($types['b'])){$background[] = $selector;}
1656
-				if(isset($types['o'])){$border[] = $selector;}
1657
-				if(isset($types['f'])){$fill[] = $selector;}
1658
-			}
1659
-
1660
-			// build rules into each type
1661
-			foreach($important_selectors as $selector => $types){
1662
-				$selector = $compatibility ? ".bsui ".$selector : $selector;
1663
-				$types = array_combine($types,$types);
1664
-				if(isset($types['c'])){$color_i[] = $selector;}
1665
-				if(isset($types['b'])){$background_i[] = $selector;}
1666
-				if(isset($types['o'])){$border_i[] = $selector;}
1667
-				if(isset($types['f'])){$fill_i[] = $selector;}
1668
-			}
1669
-
1670
-			// add any color rules
1671
-			if(!empty($color)){
1672
-				$output .= implode(",",$color) . "{color: $color_code;} ";
1673
-			}
1674
-			if(!empty($color_i)){
1675
-				$output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1676
-			}
1677
-
1678
-			// add any background color rules
1679
-			if(!empty($background)){
1680
-				$output .= implode(",",$background) . "{background-color: $color_code;} ";
1681
-			}
1682
-			if(!empty($background_i)){
1683
-				$output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1684
-			}
1685
-
1686
-			// add any border color rules
1687
-			if(!empty($border)){
1688
-				$output .= implode(",",$border) . "{border-color: $color_code;} ";
1689
-			}
1690
-			if(!empty($border_i)){
1691
-				$output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1692
-			}
1693
-
1694
-			// add any fill color rules
1695
-			if(!empty($fill)){
1696
-				$output .= implode(",",$fill) . "{fill: $color_code;} ";
1697
-			}
1698
-			if(!empty($fill_i)){
1699
-				$output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1700
-			}
1701
-
1702
-
1703
-			$prefix = $compatibility ? ".bsui " : "";
1704
-
1705
-			// darken
1706
-			$darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1707
-			$darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1708
-			$darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1709
-
1710
-			// lighten
1711
-			$lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1712
-
1713
-			// opacity see https://css-tricks.com/8-digit-hex-codes/
1714
-			$op_25 = $color_code."40"; // 25% opacity
1715
-
1716
-
1717
-			// button states
1718
-			$output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1719
-			$output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1720
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1721
-			$output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1722
-
1723
-
1724
-			return $output;
1725
-		}
1534
+            // build rules into each type
1535
+            foreach($important_selectors as $selector => $types){
1536
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1537
+                $types = array_combine($types,$types);
1538
+                if(isset($types['c'])){$color_i[] = $selector;}
1539
+                if(isset($types['b'])){$background_i[] = $selector;}
1540
+                if(isset($types['o'])){$border_i[] = $selector;}
1541
+                if(isset($types['f'])){$fill_i[] = $selector;}
1542
+            }
1726 1543
 
1727
-		/**
1728
-		 * Increases or decreases the brightness of a color by a percentage of the current brightness.
1729
-		 *
1730
-		 * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
1731
-		 * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
1732
-		 *
1733
-		 * @return  string
1734
-		 */
1735
-		public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
1736
-			$hexCode = ltrim($hexCode, '#');
1544
+            // add any color rules
1545
+            if(!empty($color)){
1546
+                $output .= implode(",",$color) . "{color: $color_code;} ";
1547
+            }
1548
+            if(!empty($color_i)){
1549
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1550
+            }
1737 1551
 
1738
-			if (strlen($hexCode) == 3) {
1739
-				$hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
1740
-			}
1552
+            // add any background color rules
1553
+            if(!empty($background)){
1554
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
1555
+            }
1556
+            if(!empty($background_i)){
1557
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1558
+            }
1741 1559
 
1742
-			$hexCode = array_map('hexdec', str_split($hexCode, 2));
1560
+            // add any border color rules
1561
+            if(!empty($border)){
1562
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
1563
+            }
1564
+            if(!empty($border_i)){
1565
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1566
+            }
1743 1567
 
1744
-			foreach ($hexCode as & $color) {
1745
-				$adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
1746
-				$adjustAmount = ceil($adjustableLimit * $adjustPercent);
1568
+            // add any fill color rules
1569
+            if(!empty($fill)){
1570
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
1571
+            }
1572
+            if(!empty($fill_i)){
1573
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1574
+            }
1747 1575
 
1748
-				$color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
1749
-			}
1750 1576
 
1751
-			return '#' . implode($hexCode);
1752
-		}
1577
+            $prefix = $compatibility ? ".bsui " : "";
1753 1578
 
1754
-		/**
1755
-		 * Check if we should display examples.
1756
-		 */
1757
-		public function maybe_show_examples(){
1758
-			if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
1759
-				echo "<head>";
1760
-				wp_head();
1761
-				echo "</head>";
1762
-				echo "<body>";
1763
-				echo $this->get_examples();
1764
-				echo "</body>";
1765
-				exit;
1766
-			}
1767
-		}
1579
+            // darken
1580
+            $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1581
+            $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1582
+            $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1768 1583
 
1769
-		/**
1770
-		 * Get developer examples.
1771
-		 *
1772
-		 * @return string
1773
-		 */
1774
-		public function get_examples(){
1775
-			$output = '';
1776
-
1777
-
1778
-			// open form
1779
-			$output .= "<form class='p-5 m-5 border rounded'>";
1780
-
1781
-			// input example
1782
-			$output .= aui()->input(array(
1783
-				'type'  =>  'text',
1784
-				'id'    =>  'text-example',
1785
-				'name'    =>  'text-example',
1786
-				'placeholder'   => 'text placeholder',
1787
-				'title'   => 'Text input example',
1788
-				'value' =>  '',
1789
-				'required'  => false,
1790
-				'help_text' => 'help text',
1791
-				'label' => 'Text input example label'
1792
-			));
1793
-
1794
-			// input example
1795
-			$output .= aui()->input(array(
1796
-				'type'  =>  'url',
1797
-				'id'    =>  'text-example2',
1798
-				'name'    =>  'text-example',
1799
-				'placeholder'   => 'url placeholder',
1800
-				'title'   => 'Text input example',
1801
-				'value' =>  '',
1802
-				'required'  => false,
1803
-				'help_text' => 'help text',
1804
-				'label' => 'Text input example label'
1805
-			));
1806
-
1807
-			// checkbox example
1808
-			$output .= aui()->input(array(
1809
-				'type'  =>  'checkbox',
1810
-				'id'    =>  'checkbox-example',
1811
-				'name'    =>  'checkbox-example',
1812
-				'placeholder'   => 'checkbox-example',
1813
-				'title'   => 'Checkbox example',
1814
-				'value' =>  '1',
1815
-				'checked'   => true,
1816
-				'required'  => false,
1817
-				'help_text' => 'help text',
1818
-				'label' => 'Checkbox checked'
1819
-			));
1820
-
1821
-			// checkbox example
1822
-			$output .= aui()->input(array(
1823
-				'type'  =>  'checkbox',
1824
-				'id'    =>  'checkbox-example2',
1825
-				'name'    =>  'checkbox-example2',
1826
-				'placeholder'   => 'checkbox-example',
1827
-				'title'   => 'Checkbox example',
1828
-				'value' =>  '1',
1829
-				'checked'   => false,
1830
-				'required'  => false,
1831
-				'help_text' => 'help text',
1832
-				'label' => 'Checkbox un-checked'
1833
-			));
1834
-
1835
-			// switch example
1836
-			$output .= aui()->input(array(
1837
-				'type'  =>  'checkbox',
1838
-				'id'    =>  'switch-example',
1839
-				'name'    =>  'switch-example',
1840
-				'placeholder'   => 'checkbox-example',
1841
-				'title'   => 'Switch example',
1842
-				'value' =>  '1',
1843
-				'checked'   => true,
1844
-				'switch'    => true,
1845
-				'required'  => false,
1846
-				'help_text' => 'help text',
1847
-				'label' => 'Switch on'
1848
-			));
1849
-
1850
-			// switch example
1851
-			$output .= aui()->input(array(
1852
-				'type'  =>  'checkbox',
1853
-				'id'    =>  'switch-example2',
1854
-				'name'    =>  'switch-example2',
1855
-				'placeholder'   => 'checkbox-example',
1856
-				'title'   => 'Switch example',
1857
-				'value' =>  '1',
1858
-				'checked'   => false,
1859
-				'switch'    => true,
1860
-				'required'  => false,
1861
-				'help_text' => 'help text',
1862
-				'label' => 'Switch off'
1863
-			));
1864
-
1865
-			// close form
1866
-			$output .= "</form>";
1867
-
1868
-			return $output;
1869
-		}
1584
+            // lighten
1585
+            $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1870 1586
 
1871
-		/**
1872
-		 * Calendar params.
1873
-		 *
1874
-		 * @since 0.1.44
1875
-		 *
1876
-		 * @return array Calendar params.
1877
-		 */
1878
-		public static function calendar_params() {
1879
-			$params = array(
1880
-				'month_long_1' => __( 'January', 'aui' ),
1881
-				'month_long_2' => __( 'February', 'aui' ),
1882
-				'month_long_3' => __( 'March', 'aui' ),
1883
-				'month_long_4' => __( 'April', 'aui' ),
1884
-				'month_long_5' => __( 'May', 'aui' ),
1885
-				'month_long_6' => __( 'June', 'aui' ),
1886
-				'month_long_7' => __( 'July', 'aui' ),
1887
-				'month_long_8' => __( 'August', 'aui' ),
1888
-				'month_long_9' => __( 'September', 'aui' ),
1889
-				'month_long_10' => __( 'October', 'aui' ),
1890
-				'month_long_11' => __( 'November', 'aui' ),
1891
-				'month_long_12' => __( 'December', 'aui' ),
1892
-				'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ),
1893
-				'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ),
1894
-				'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ),
1895
-				'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ),
1896
-				'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ),
1897
-				'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ),
1898
-				'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ),
1899
-				'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ),
1900
-				'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ),
1901
-				'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ),
1902
-				'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ),
1903
-				'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ),
1904
-				'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ),
1905
-				'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ),
1906
-				'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ),
1907
-				'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ),
1908
-				'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ),
1909
-				'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ),
1910
-				'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ),
1911
-				'day_s2_1' => __( 'Su', 'aui' ),
1912
-				'day_s2_2' => __( 'Mo', 'aui' ),
1913
-				'day_s2_3' => __( 'Tu', 'aui' ),
1914
-				'day_s2_4' => __( 'We', 'aui' ),
1915
-				'day_s2_5' => __( 'Th', 'aui' ),
1916
-				'day_s2_6' => __( 'Fr', 'aui' ),
1917
-				'day_s2_7' => __( 'Sa', 'aui' ),
1918
-				'day_s3_1' => __( 'Sun', 'aui' ),
1919
-				'day_s3_2' => __( 'Mon', 'aui' ),
1920
-				'day_s3_3' => __( 'Tue', 'aui' ),
1921
-				'day_s3_4' => __( 'Wed', 'aui' ),
1922
-				'day_s3_5' => __( 'Thu', 'aui' ),
1923
-				'day_s3_6' => __( 'Fri', 'aui' ),
1924
-				'day_s3_7' => __( 'Sat', 'aui' ),
1925
-				'day_s5_1' => __( 'Sunday', 'aui' ),
1926
-				'day_s5_2' => __( 'Monday', 'aui' ),
1927
-				'day_s5_3' => __( 'Tuesday', 'aui' ),
1928
-				'day_s5_4' => __( 'Wednesday', 'aui' ),
1929
-				'day_s5_5' => __( 'Thursday', 'aui' ),
1930
-				'day_s5_6' => __( 'Friday', 'aui' ),
1931
-				'day_s5_7' => __( 'Saturday', 'aui' ),
1932
-				'am_lower' => __( 'am', 'aui' ),
1933
-				'pm_lower' => __( 'pm', 'aui' ),
1934
-				'am_upper' => __( 'AM', 'aui' ),
1935
-				'pm_upper' => __( 'PM', 'aui' ),
1936
-				'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
1937
-				'time_24hr' => false,
1938
-				'year' => __( 'Year', 'aui' ),
1939
-				'hour' => __( 'Hour', 'aui' ),
1940
-				'minute' => __( 'Minute', 'aui' ),
1941
-				'weekAbbreviation' => __( 'Wk', 'aui' ),
1942
-				'rangeSeparator' => __( ' to ', 'aui' ),
1943
-				'scrollTitle' => __( 'Scroll to increment', 'aui' ),
1944
-				'toggleTitle' => __( 'Click to toggle', 'aui' )
1945
-			);
1946
-
1947
-			return apply_filters( 'ayecode_ui_calendar_params', $params );
1948
-		}
1587
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
1588
+            $op_25 = $color_code."40"; // 25% opacity
1949 1589
 
1950
-		/**
1951
-		 * Flatpickr calendar localize.
1952
-		 *
1953
-		 * @since 0.1.44
1954
-		 *
1955
-		 * @return string Calendar locale.
1956
-		 */
1957
-		public static function flatpickr_locale() {
1958
-			$params = self::calendar_params();
1959
-
1960
-			if ( is_string( $params ) ) {
1961
-				$params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
1962
-			} else {
1963
-				foreach ( (array) $params as $key => $value ) {
1964
-					if ( ! is_scalar( $value ) ) {
1965
-						continue;
1966
-					}
1967 1590
 
1968
-					$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
1969
-				}
1970
-			}
1591
+            // button states
1592
+            $output .= $prefix ." .btn-primary:hover, $prefix .btn-primary:focus, $prefix .btn-primary.focus{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1593
+            $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1594
+            $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1595
+            $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1596
+
1597
+
1598
+            // dropdown's
1599
+            $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} ";
1971 1600
 
1972
-			$day_s3 = array();
1973
-			$day_s5 = array();
1974 1601
 
1975
-			for ( $i = 1; $i <= 7; $i ++ ) {
1976
-				$day_s3[] = addslashes( $params[ 'day_s3_' . $i ] );
1977
-				$day_s5[] = addslashes( $params[ 'day_s3_' . $i ] );
1978
-			}
1602
+            // input states
1603
+            $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} ";
1979 1604
 
1980
-			$month_s = array();
1981
-			$month_long = array();
1605
+            // page link
1606
+            $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1607
+
1608
+            return $output;
1609
+        }
1610
+
1611
+        public static function css_secondary($color_code,$compatibility){;
1612
+            $color_code = sanitize_hex_color($color_code);
1613
+            if(!$color_code){return '';}
1614
+            /**
1615
+             * c = color, b = background color, o = border-color, f = fill
1616
+             */
1617
+            $selectors = array(
1618
+                '.btn-secondary' => array('b','o'),
1619
+                '.btn-secondary.disabled' => array('b','o'),
1620
+                '.btn-secondary:disabled' => array('b','o'),
1621
+                '.btn-outline-secondary' => array('c','o'),
1622
+                '.btn-outline-secondary:hover' => array('b','o'),
1623
+                '.btn-outline-secondary.disabled' => array('c'),
1624
+                '.btn-outline-secondary:disabled' => array('c'),
1625
+                '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'),
1626
+                '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'),
1627
+                '.btn-outline-secondary.dropdown-toggle' => array('b','o'),
1628
+                '.badge-secondary' => array('b'),
1629
+                '.alert-secondary' => array('b','o'),
1630
+                '.btn-link.btn-secondary' => array('c'),
1631
+            );
1632
+
1633
+            $important_selectors = array(
1634
+                '.bg-secondary' => array('b','f'),
1635
+                '.border-secondary' => array('o'),
1636
+                '.text-secondary' => array('c'),
1637
+            );
1638
+
1639
+            $color = array();
1640
+            $color_i = array();
1641
+            $background = array();
1642
+            $background_i = array();
1643
+            $border = array();
1644
+            $border_i = array();
1645
+            $fill = array();
1646
+            $fill_i = array();
1647
+
1648
+            $output = '';
1649
+
1650
+            // build rules into each type
1651
+            foreach($selectors as $selector => $types){
1652
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1653
+                $types = array_combine($types,$types);
1654
+                if(isset($types['c'])){$color[] = $selector;}
1655
+                if(isset($types['b'])){$background[] = $selector;}
1656
+                if(isset($types['o'])){$border[] = $selector;}
1657
+                if(isset($types['f'])){$fill[] = $selector;}
1658
+            }
1659
+
1660
+            // build rules into each type
1661
+            foreach($important_selectors as $selector => $types){
1662
+                $selector = $compatibility ? ".bsui ".$selector : $selector;
1663
+                $types = array_combine($types,$types);
1664
+                if(isset($types['c'])){$color_i[] = $selector;}
1665
+                if(isset($types['b'])){$background_i[] = $selector;}
1666
+                if(isset($types['o'])){$border_i[] = $selector;}
1667
+                if(isset($types['f'])){$fill_i[] = $selector;}
1668
+            }
1982 1669
 
1983
-			for ( $i = 1; $i <= 12; $i ++ ) {
1984
-				$month_s[] = addslashes( $params[ 'month_s_' . $i ] );
1985
-				$month_long[] = addslashes( $params[ 'month_long_' . $i ] );
1986
-			}
1670
+            // add any color rules
1671
+            if(!empty($color)){
1672
+                $output .= implode(",",$color) . "{color: $color_code;} ";
1673
+            }
1674
+            if(!empty($color_i)){
1675
+                $output .= implode(",",$color_i) . "{color: $color_code !important;} ";
1676
+            }
1677
+
1678
+            // add any background color rules
1679
+            if(!empty($background)){
1680
+                $output .= implode(",",$background) . "{background-color: $color_code;} ";
1681
+            }
1682
+            if(!empty($background_i)){
1683
+                $output .= implode(",",$background_i) . "{background-color: $color_code !important;} ";
1684
+            }
1685
+
1686
+            // add any border color rules
1687
+            if(!empty($border)){
1688
+                $output .= implode(",",$border) . "{border-color: $color_code;} ";
1689
+            }
1690
+            if(!empty($border_i)){
1691
+                $output .= implode(",",$border_i) . "{border-color: $color_code !important;} ";
1692
+            }
1693
+
1694
+            // add any fill color rules
1695
+            if(!empty($fill)){
1696
+                $output .= implode(",",$fill) . "{fill: $color_code;} ";
1697
+            }
1698
+            if(!empty($fill_i)){
1699
+                $output .= implode(",",$fill_i) . "{fill: $color_code !important;} ";
1700
+            }
1701
+
1702
+
1703
+            $prefix = $compatibility ? ".bsui " : "";
1704
+
1705
+            // darken
1706
+            $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075");
1707
+            $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10");
1708
+            $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125");
1709
+
1710
+            // lighten
1711
+            $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25");
1712
+
1713
+            // opacity see https://css-tricks.com/8-digit-hex-codes/
1714
+            $op_25 = $color_code."40"; // 25% opacity
1715
+
1716
+
1717
+            // button states
1718
+            $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075.";    border-color: ".$darker_10.";} ";
1719
+            $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} ";
1720
+            $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10.";    border-color: ".$darker_125.";} ";
1721
+            $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} ";
1722
+
1723
+
1724
+            return $output;
1725
+        }
1726
+
1727
+        /**
1728
+         * Increases or decreases the brightness of a color by a percentage of the current brightness.
1729
+         *
1730
+         * @param   string  $hexCode        Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF`
1731
+         * @param   float   $adjustPercent  A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker.
1732
+         *
1733
+         * @return  string
1734
+         */
1735
+        public static function css_hex_lighten_darken($hexCode, $adjustPercent) {
1736
+            $hexCode = ltrim($hexCode, '#');
1737
+
1738
+            if (strlen($hexCode) == 3) {
1739
+                $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2];
1740
+            }
1741
+
1742
+            $hexCode = array_map('hexdec', str_split($hexCode, 2));
1743
+
1744
+            foreach ($hexCode as & $color) {
1745
+                $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color;
1746
+                $adjustAmount = ceil($adjustableLimit * $adjustPercent);
1747
+
1748
+                $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT);
1749
+            }
1750
+
1751
+            return '#' . implode($hexCode);
1752
+        }
1753
+
1754
+        /**
1755
+         * Check if we should display examples.
1756
+         */
1757
+        public function maybe_show_examples(){
1758
+            if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
1759
+                echo "<head>";
1760
+                wp_head();
1761
+                echo "</head>";
1762
+                echo "<body>";
1763
+                echo $this->get_examples();
1764
+                echo "</body>";
1765
+                exit;
1766
+            }
1767
+        }
1768
+
1769
+        /**
1770
+         * Get developer examples.
1771
+         *
1772
+         * @return string
1773
+         */
1774
+        public function get_examples(){
1775
+            $output = '';
1776
+
1777
+
1778
+            // open form
1779
+            $output .= "<form class='p-5 m-5 border rounded'>";
1780
+
1781
+            // input example
1782
+            $output .= aui()->input(array(
1783
+                'type'  =>  'text',
1784
+                'id'    =>  'text-example',
1785
+                'name'    =>  'text-example',
1786
+                'placeholder'   => 'text placeholder',
1787
+                'title'   => 'Text input example',
1788
+                'value' =>  '',
1789
+                'required'  => false,
1790
+                'help_text' => 'help text',
1791
+                'label' => 'Text input example label'
1792
+            ));
1793
+
1794
+            // input example
1795
+            $output .= aui()->input(array(
1796
+                'type'  =>  'url',
1797
+                'id'    =>  'text-example2',
1798
+                'name'    =>  'text-example',
1799
+                'placeholder'   => 'url placeholder',
1800
+                'title'   => 'Text input example',
1801
+                'value' =>  '',
1802
+                'required'  => false,
1803
+                'help_text' => 'help text',
1804
+                'label' => 'Text input example label'
1805
+            ));
1806
+
1807
+            // checkbox example
1808
+            $output .= aui()->input(array(
1809
+                'type'  =>  'checkbox',
1810
+                'id'    =>  'checkbox-example',
1811
+                'name'    =>  'checkbox-example',
1812
+                'placeholder'   => 'checkbox-example',
1813
+                'title'   => 'Checkbox example',
1814
+                'value' =>  '1',
1815
+                'checked'   => true,
1816
+                'required'  => false,
1817
+                'help_text' => 'help text',
1818
+                'label' => 'Checkbox checked'
1819
+            ));
1820
+
1821
+            // checkbox example
1822
+            $output .= aui()->input(array(
1823
+                'type'  =>  'checkbox',
1824
+                'id'    =>  'checkbox-example2',
1825
+                'name'    =>  'checkbox-example2',
1826
+                'placeholder'   => 'checkbox-example',
1827
+                'title'   => 'Checkbox example',
1828
+                'value' =>  '1',
1829
+                'checked'   => false,
1830
+                'required'  => false,
1831
+                'help_text' => 'help text',
1832
+                'label' => 'Checkbox un-checked'
1833
+            ));
1834
+
1835
+            // switch example
1836
+            $output .= aui()->input(array(
1837
+                'type'  =>  'checkbox',
1838
+                'id'    =>  'switch-example',
1839
+                'name'    =>  'switch-example',
1840
+                'placeholder'   => 'checkbox-example',
1841
+                'title'   => 'Switch example',
1842
+                'value' =>  '1',
1843
+                'checked'   => true,
1844
+                'switch'    => true,
1845
+                'required'  => false,
1846
+                'help_text' => 'help text',
1847
+                'label' => 'Switch on'
1848
+            ));
1849
+
1850
+            // switch example
1851
+            $output .= aui()->input(array(
1852
+                'type'  =>  'checkbox',
1853
+                'id'    =>  'switch-example2',
1854
+                'name'    =>  'switch-example2',
1855
+                'placeholder'   => 'checkbox-example',
1856
+                'title'   => 'Switch example',
1857
+                'value' =>  '1',
1858
+                'checked'   => false,
1859
+                'switch'    => true,
1860
+                'required'  => false,
1861
+                'help_text' => 'help text',
1862
+                'label' => 'Switch off'
1863
+            ));
1864
+
1865
+            // close form
1866
+            $output .= "</form>";
1867
+
1868
+            return $output;
1869
+        }
1870
+
1871
+        /**
1872
+         * Calendar params.
1873
+         *
1874
+         * @since 0.1.44
1875
+         *
1876
+         * @return array Calendar params.
1877
+         */
1878
+        public static function calendar_params() {
1879
+            $params = array(
1880
+                'month_long_1' => __( 'January', 'aui' ),
1881
+                'month_long_2' => __( 'February', 'aui' ),
1882
+                'month_long_3' => __( 'March', 'aui' ),
1883
+                'month_long_4' => __( 'April', 'aui' ),
1884
+                'month_long_5' => __( 'May', 'aui' ),
1885
+                'month_long_6' => __( 'June', 'aui' ),
1886
+                'month_long_7' => __( 'July', 'aui' ),
1887
+                'month_long_8' => __( 'August', 'aui' ),
1888
+                'month_long_9' => __( 'September', 'aui' ),
1889
+                'month_long_10' => __( 'October', 'aui' ),
1890
+                'month_long_11' => __( 'November', 'aui' ),
1891
+                'month_long_12' => __( 'December', 'aui' ),
1892
+                'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ),
1893
+                'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ),
1894
+                'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ),
1895
+                'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ),
1896
+                'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ),
1897
+                'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ),
1898
+                'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ),
1899
+                'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ),
1900
+                'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ),
1901
+                'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ),
1902
+                'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ),
1903
+                'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ),
1904
+                'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ),
1905
+                'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ),
1906
+                'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ),
1907
+                'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ),
1908
+                'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ),
1909
+                'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ),
1910
+                'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ),
1911
+                'day_s2_1' => __( 'Su', 'aui' ),
1912
+                'day_s2_2' => __( 'Mo', 'aui' ),
1913
+                'day_s2_3' => __( 'Tu', 'aui' ),
1914
+                'day_s2_4' => __( 'We', 'aui' ),
1915
+                'day_s2_5' => __( 'Th', 'aui' ),
1916
+                'day_s2_6' => __( 'Fr', 'aui' ),
1917
+                'day_s2_7' => __( 'Sa', 'aui' ),
1918
+                'day_s3_1' => __( 'Sun', 'aui' ),
1919
+                'day_s3_2' => __( 'Mon', 'aui' ),
1920
+                'day_s3_3' => __( 'Tue', 'aui' ),
1921
+                'day_s3_4' => __( 'Wed', 'aui' ),
1922
+                'day_s3_5' => __( 'Thu', 'aui' ),
1923
+                'day_s3_6' => __( 'Fri', 'aui' ),
1924
+                'day_s3_7' => __( 'Sat', 'aui' ),
1925
+                'day_s5_1' => __( 'Sunday', 'aui' ),
1926
+                'day_s5_2' => __( 'Monday', 'aui' ),
1927
+                'day_s5_3' => __( 'Tuesday', 'aui' ),
1928
+                'day_s5_4' => __( 'Wednesday', 'aui' ),
1929
+                'day_s5_5' => __( 'Thursday', 'aui' ),
1930
+                'day_s5_6' => __( 'Friday', 'aui' ),
1931
+                'day_s5_7' => __( 'Saturday', 'aui' ),
1932
+                'am_lower' => __( 'am', 'aui' ),
1933
+                'pm_lower' => __( 'pm', 'aui' ),
1934
+                'am_upper' => __( 'AM', 'aui' ),
1935
+                'pm_upper' => __( 'PM', 'aui' ),
1936
+                'firstDayOfWeek' => (int) get_option( 'start_of_week' ),
1937
+                'time_24hr' => false,
1938
+                'year' => __( 'Year', 'aui' ),
1939
+                'hour' => __( 'Hour', 'aui' ),
1940
+                'minute' => __( 'Minute', 'aui' ),
1941
+                'weekAbbreviation' => __( 'Wk', 'aui' ),
1942
+                'rangeSeparator' => __( ' to ', 'aui' ),
1943
+                'scrollTitle' => __( 'Scroll to increment', 'aui' ),
1944
+                'toggleTitle' => __( 'Click to toggle', 'aui' )
1945
+            );
1946
+
1947
+            return apply_filters( 'ayecode_ui_calendar_params', $params );
1948
+        }
1949
+
1950
+        /**
1951
+         * Flatpickr calendar localize.
1952
+         *
1953
+         * @since 0.1.44
1954
+         *
1955
+         * @return string Calendar locale.
1956
+         */
1957
+        public static function flatpickr_locale() {
1958
+            $params = self::calendar_params();
1959
+
1960
+            if ( is_string( $params ) ) {
1961
+                $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' );
1962
+            } else {
1963
+                foreach ( (array) $params as $key => $value ) {
1964
+                    if ( ! is_scalar( $value ) ) {
1965
+                        continue;
1966
+                    }
1967
+
1968
+                    $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
1969
+                }
1970
+            }
1971
+
1972
+            $day_s3 = array();
1973
+            $day_s5 = array();
1974
+
1975
+            for ( $i = 1; $i <= 7; $i ++ ) {
1976
+                $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] );
1977
+                $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] );
1978
+            }
1979
+
1980
+            $month_s = array();
1981
+            $month_long = array();
1982
+
1983
+            for ( $i = 1; $i <= 12; $i ++ ) {
1984
+                $month_s[] = addslashes( $params[ 'month_s_' . $i ] );
1985
+                $month_long[] = addslashes( $params[ 'month_long_' . $i ] );
1986
+            }
1987 1987
 
1988 1988
 ob_start();
1989 1989
 if ( 0 ) { ?><script><?php } ?>
@@ -2025,189 +2025,189 @@  discard block
 block discarded – undo
2025 2025
 }
2026 2026
 <?php if ( 0 ) { ?></script><?php } ?>
2027 2027
 <?php
2028
-			$locale = ob_get_clean();
2028
+            $locale = ob_get_clean();
2029 2029
 
2030
-			return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2031
-		}
2030
+            return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) );
2031
+        }
2032 2032
 
2033
-		/**
2034
-		 * Select2 JS params.
2035
-		 *
2036
-		 * @since 0.1.44
2037
-		 *
2038
-		 * @return array Select2 JS params.
2039
-		 */
2040
-		public static function select2_params() {
2041
-			$params = array(
2042
-				'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'aui' ),
2043
-				'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'aui' ),
2044
-				'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'aui' ),
2045
-				'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ),
2046
-				'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ),
2047
-				'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'aui' ),
2048
-				'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ),
2049
-				'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ),
2050
-				'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ),
2051
-				'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'aui' ),
2052
-				'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'aui' )
2053
-			);
2054
-
2055
-			return apply_filters( 'ayecode_ui_select2_params', $params );
2056
-		}
2033
+        /**
2034
+         * Select2 JS params.
2035
+         *
2036
+         * @since 0.1.44
2037
+         *
2038
+         * @return array Select2 JS params.
2039
+         */
2040
+        public static function select2_params() {
2041
+            $params = array(
2042
+                'i18n_select_state_text'    => esc_attr__( 'Select an option&hellip;', 'aui' ),
2043
+                'i18n_no_matches'           => _x( 'No matches found', 'enhanced select', 'aui' ),
2044
+                'i18n_ajax_error'           => _x( 'Loading failed', 'enhanced select', 'aui' ),
2045
+                'i18n_input_too_short_1'    => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ),
2046
+                'i18n_input_too_short_n'    => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ),
2047
+                'i18n_input_too_long_1'     => _x( 'Please delete 1 character', 'enhanced select', 'aui' ),
2048
+                'i18n_input_too_long_n'     => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ),
2049
+                'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ),
2050
+                'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ),
2051
+                'i18n_load_more'            => _x( 'Loading more results&hellip;', 'enhanced select', 'aui' ),
2052
+                'i18n_searching'            => _x( 'Searching&hellip;', 'enhanced select', 'aui' )
2053
+            );
2054
+
2055
+            return apply_filters( 'ayecode_ui_select2_params', $params );
2056
+        }
2057 2057
 
2058
-		/**
2059
-		 * Select2 JS localize.
2060
-		 *
2061
-		 * @since 0.1.44
2062
-		 *
2063
-		 * @return string Select2 JS locale.
2064
-		 */
2065
-		public static function select2_locale() {
2066
-			$params = self::select2_params();
2067
-
2068
-			foreach ( (array) $params as $key => $value ) {
2069
-				if ( ! is_scalar( $value ) ) {
2070
-					continue;
2071
-				}
2058
+        /**
2059
+         * Select2 JS localize.
2060
+         *
2061
+         * @since 0.1.44
2062
+         *
2063
+         * @return string Select2 JS locale.
2064
+         */
2065
+        public static function select2_locale() {
2066
+            $params = self::select2_params();
2067
+
2068
+            foreach ( (array) $params as $key => $value ) {
2069
+                if ( ! is_scalar( $value ) ) {
2070
+                    continue;
2071
+                }
2072 2072
 
2073
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2074
-			}
2073
+                $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2074
+            }
2075 2075
 
2076
-			$locale = json_encode( $params );
2076
+            $locale = json_encode( $params );
2077 2077
 
2078
-			return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2079
-		}
2078
+            return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) );
2079
+        }
2080 2080
 
2081
-		/**
2082
-		 * Time ago JS localize.
2083
-		 *
2084
-		 * @since 0.1.47
2085
-		 *
2086
-		 * @return string Time ago JS locale.
2087
-		 */
2088
-		public static function timeago_locale() {
2089
-			$params = array(
2090
-				'prefix_ago' => '',
2091
-				'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ),
2092
-				'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ',
2093
-				'suffix_after' => '',
2094
-				'seconds' => _x( 'less than a minute', 'time ago', 'aui' ),
2095
-				'minute' => _x( 'about a minute', 'time ago', 'aui' ),
2096
-				'minutes' => _x( '%d minutes', 'time ago', 'aui' ),
2097
-				'hour' => _x( 'about an hour', 'time ago', 'aui' ),
2098
-				'hours' => _x( 'about %d hours', 'time ago', 'aui' ),
2099
-				'day' => _x( 'a day', 'time ago', 'aui' ),
2100
-				'days' => _x( '%d days', 'time ago', 'aui' ),
2101
-				'month' => _x( 'about a month', 'time ago', 'aui' ),
2102
-				'months' => _x( '%d months', 'time ago', 'aui' ),
2103
-				'year' => _x( 'about a year', 'time ago', 'aui' ),
2104
-				'years' => _x( '%d years', 'time ago', 'aui' ),
2105
-			);
2106
-
2107
-			$params = apply_filters( 'ayecode_ui_timeago_params', $params );
2108
-
2109
-			foreach ( (array) $params as $key => $value ) {
2110
-				if ( ! is_scalar( $value ) ) {
2111
-					continue;
2112
-				}
2081
+        /**
2082
+         * Time ago JS localize.
2083
+         *
2084
+         * @since 0.1.47
2085
+         *
2086
+         * @return string Time ago JS locale.
2087
+         */
2088
+        public static function timeago_locale() {
2089
+            $params = array(
2090
+                'prefix_ago' => '',
2091
+                'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ),
2092
+                'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ',
2093
+                'suffix_after' => '',
2094
+                'seconds' => _x( 'less than a minute', 'time ago', 'aui' ),
2095
+                'minute' => _x( 'about a minute', 'time ago', 'aui' ),
2096
+                'minutes' => _x( '%d minutes', 'time ago', 'aui' ),
2097
+                'hour' => _x( 'about an hour', 'time ago', 'aui' ),
2098
+                'hours' => _x( 'about %d hours', 'time ago', 'aui' ),
2099
+                'day' => _x( 'a day', 'time ago', 'aui' ),
2100
+                'days' => _x( '%d days', 'time ago', 'aui' ),
2101
+                'month' => _x( 'about a month', 'time ago', 'aui' ),
2102
+                'months' => _x( '%d months', 'time ago', 'aui' ),
2103
+                'year' => _x( 'about a year', 'time ago', 'aui' ),
2104
+                'years' => _x( '%d years', 'time ago', 'aui' ),
2105
+            );
2106
+
2107
+            $params = apply_filters( 'ayecode_ui_timeago_params', $params );
2108
+
2109
+            foreach ( (array) $params as $key => $value ) {
2110
+                if ( ! is_scalar( $value ) ) {
2111
+                    continue;
2112
+                }
2113 2113
 
2114
-				$params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2115
-			}
2114
+                $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
2115
+            }
2116 2116
 
2117
-			$locale = json_encode( $params );
2117
+            $locale = json_encode( $params );
2118 2118
 
2119
-			return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2120
-		}
2119
+            return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) );
2120
+        }
2121 2121
 
2122
-		/**
2123
-		 * JavaScript Minifier
2124
-		 *
2125
-		 * @param $input
2126
-		 *
2127
-		 * @return mixed
2128
-		 */
2129
-		public static function minify_js($input) {
2130
-			if(trim($input) === "") return $input;
2131
-			return preg_replace(
2132
-				array(
2133
-					// Remove comment(s)
2134
-					'#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
2135
-					// Remove white-space(s) outside the string and regex
2136
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
2137
-					// Remove the last semicolon
2138
-					'#;+\}#',
2139
-					// Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
2140
-					'#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
2141
-					// --ibid. From `foo['bar']` to `foo.bar`
2142
-					'#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
2143
-				),
2144
-				array(
2145
-					'$1',
2146
-					'$1$2',
2147
-					'}',
2148
-					'$1$3',
2149
-					'$1.$3'
2150
-				),
2151
-				$input);
2152
-		}
2122
+        /**
2123
+         * JavaScript Minifier
2124
+         *
2125
+         * @param $input
2126
+         *
2127
+         * @return mixed
2128
+         */
2129
+        public static function minify_js($input) {
2130
+            if(trim($input) === "") return $input;
2131
+            return preg_replace(
2132
+                array(
2133
+                    // Remove comment(s)
2134
+                    '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#',
2135
+                    // Remove white-space(s) outside the string and regex
2136
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s',
2137
+                    // Remove the last semicolon
2138
+                    '#;+\}#',
2139
+                    // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}`
2140
+                    '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i',
2141
+                    // --ibid. From `foo['bar']` to `foo.bar`
2142
+                    '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i'
2143
+                ),
2144
+                array(
2145
+                    '$1',
2146
+                    '$1$2',
2147
+                    '}',
2148
+                    '$1$3',
2149
+                    '$1.$3'
2150
+                ),
2151
+                $input);
2152
+        }
2153 2153
 
2154
-		/**
2155
-		 * Minify CSS
2156
-		 *
2157
-		 * @param $input
2158
-		 *
2159
-		 * @return mixed
2160
-		 */
2161
-		public static function minify_css($input) {
2162
-			if(trim($input) === "") return $input;
2163
-			return preg_replace(
2164
-				array(
2165
-					// Remove comment(s)
2166
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
2167
-					// Remove unused white-space(s)
2168
-					'#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
2169
-					// Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
2170
-					'#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
2171
-					// Replace `:0 0 0 0` with `:0`
2172
-					'#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
2173
-					// Replace `background-position:0` with `background-position:0 0`
2174
-					'#(background-position):0(?=[;\}])#si',
2175
-					// Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
2176
-					'#(?<=[\s:,\-])0+\.(\d+)#s',
2177
-					// Minify string value
2178
-					'#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
2179
-					'#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
2180
-					// Minify HEX color code
2181
-					'#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
2182
-					// Replace `(border|outline):none` with `(border|outline):0`
2183
-					'#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
2184
-					// Remove empty selector(s)
2185
-					'#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
2186
-				),
2187
-				array(
2188
-					'$1',
2189
-					'$1$2$3$4$5$6$7',
2190
-					'$1',
2191
-					':0',
2192
-					'$1:0 0',
2193
-					'.$1',
2194
-					'$1$3',
2195
-					'$1$2$4$5',
2196
-					'$1$2$3',
2197
-					'$1:0',
2198
-					'$1$2'
2199
-				),
2200
-				$input);
2201
-		}
2154
+        /**
2155
+         * Minify CSS
2156
+         *
2157
+         * @param $input
2158
+         *
2159
+         * @return mixed
2160
+         */
2161
+        public static function minify_css($input) {
2162
+            if(trim($input) === "") return $input;
2163
+            return preg_replace(
2164
+                array(
2165
+                    // Remove comment(s)
2166
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s',
2167
+                    // Remove unused white-space(s)
2168
+                    '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si',
2169
+                    // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
2170
+                    '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si',
2171
+                    // Replace `:0 0 0 0` with `:0`
2172
+                    '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i',
2173
+                    // Replace `background-position:0` with `background-position:0 0`
2174
+                    '#(background-position):0(?=[;\}])#si',
2175
+                    // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
2176
+                    '#(?<=[\s:,\-])0+\.(\d+)#s',
2177
+                    // Minify string value
2178
+                    '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si',
2179
+                    '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si',
2180
+                    // Minify HEX color code
2181
+                    '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i',
2182
+                    // Replace `(border|outline):none` with `(border|outline):0`
2183
+                    '#(?<=[\{;])(border|outline):none(?=[;\}\!])#',
2184
+                    // Remove empty selector(s)
2185
+                    '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s'
2186
+                ),
2187
+                array(
2188
+                    '$1',
2189
+                    '$1$2$3$4$5$6$7',
2190
+                    '$1',
2191
+                    ':0',
2192
+                    '$1:0 0',
2193
+                    '.$1',
2194
+                    '$1$3',
2195
+                    '$1$2$4$5',
2196
+                    '$1$2$3',
2197
+                    '$1:0',
2198
+                    '$1$2'
2199
+                ),
2200
+                $input);
2201
+        }
2202 2202
 
2203
-		/**
2204
-		 * Get the conditional fields JavaScript.
2205
-		 *
2206
-		 * @return mixed
2207
-		 */
2208
-		public function conditional_fields_js() {
2209
-			ob_start();
2210
-			?>
2203
+        /**
2204
+         * Get the conditional fields JavaScript.
2205
+         *
2206
+         * @return mixed
2207
+         */
2208
+        public function conditional_fields_js() {
2209
+            ob_start();
2210
+            ?>
2211 2211
 <script>
2212 2212
 /**
2213 2213
  * Conditional Fields
@@ -2711,14 +2711,14 @@  discard block
 block discarded – undo
2711 2711
 <?php do_action( 'aui_conditional_fields_js', $this ); ?>
2712 2712
 </script>
2713 2713
 			<?php
2714
-			$output = ob_get_clean();
2714
+            $output = ob_get_clean();
2715 2715
 
2716
-			return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
2717
-		}
2718
-	}
2716
+            return str_replace( array( '<script>', '</script>' ), '', self::minify_js( $output ) );
2717
+        }
2718
+    }
2719 2719
 
2720
-	/**
2721
-	 * Run the class if found.
2722
-	 */
2723
-	AyeCode_UI_Settings::instance();
2720
+    /**
2721
+     * Run the class if found.
2722
+     */
2723
+    AyeCode_UI_Settings::instance();
2724 2724
 }
2725 2725
\ No newline at end of file
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 1 patch
Indentation   +1046 added lines, -1046 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,1056 +11,1056 @@  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_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
36
-			'help_text'  => '',
37
-			'validation_text'   => '',
38
-			'validation_pattern' => '',
39
-			'no_wrap'    => false,
40
-			'input_group_right' => '',
41
-			'input_group_left' => '',
42
-			'input_group_right_inside' => false, // forces the input group inside the input
43
-			'input_group_left_inside' => false, // forces the input group inside the input
44
-			'step'       => '',
45
-			'switch'     => false, // to show checkbox as a switch
46
-			'checked'   => false, // set a checkbox or radio as selected
47
-			'password_toggle' => true, // toggle view/hide password
48
-			'element_require'   => '', // [%element_id%] == "1"
49
-			'extra_attributes'  => array(), // an array of extra attributes
50
-			'wrap_attributes' => array()
51
-		);
52
-
53
-		/**
54
-		 * Parse incoming $args into an array and merge it with $defaults
55
-		 */
56
-		$args   = wp_parse_args( $args, $defaults );
57
-		$output = '';
58
-		if ( ! empty( $args['type'] ) ) {
59
-			// hidden label option needs to be empty
60
-			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
61
-
62
-			$type = sanitize_html_class( $args['type'] );
63
-
64
-			$help_text = '';
65
-			$label = '';
66
-			$label_after = $args['label_after'];
67
-			$label_args = array(
68
-				'title'=> $args['label'],
69
-				'for'=> $args['id'],
70
-				'class' => $args['label_class']." ",
71
-				'label_type' => $args['label_type']
72
-			);
73
-
74
-			// floating labels need label after
75
-			if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
76
-				$label_after = true;
77
-				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
78
-			}
79
-
80
-			// Some special sauce for files
81
-			if($type=='file' ){
82
-				$label_after = true; // if type file we need the label after
83
-				$args['class'] .= ' custom-file-input ';
84
-			}elseif($type=='checkbox'){
85
-				$label_after = true; // if type file we need the label after
86
-				$args['class'] .= ' custom-control-input ';
87
-			}elseif($type=='datepicker' || $type=='timepicker'){
88
-				$type = 'text';
89
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
90
-				$args['class'] .= ' bg-initial ';
91
-
92
-				$args['extra_attributes']['data-aui-init'] = 'flatpickr';
93
-				// enqueue the script
94
-				$aui_settings = AyeCode_UI_Settings::instance();
95
-				$aui_settings->enqueue_flatpickr();
96
-			}
97
-
98
-
99
-			// open/type
100
-			$output .= '<input type="' . $type . '" ';
101
-
102
-			// name
103
-			if(!empty($args['name'])){
104
-				$output .= ' name="'.esc_attr($args['name']).'" ';
105
-			}
106
-
107
-			// id
108
-			if(!empty($args['id'])){
109
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
110
-			}
111
-
112
-			// placeholder
113
-			if(isset($args['placeholder']) && '' != $args['placeholder'] ){
114
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
115
-			}
116
-
117
-			// title
118
-			if(!empty($args['title'])){
119
-				$output .= ' title="'.esc_attr($args['title']).'" ';
120
-			}
121
-
122
-			// value
123
-			if(!empty($args['value'])){
124
-				$output .= AUI_Component_Helper::value($args['value']);
125
-			}
126
-
127
-			// checked, for radio and checkboxes
128
-			if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
129
-				$output .= ' checked ';
130
-			}
131
-
132
-			// validation text
133
-			if(!empty($args['validation_text'])){
134
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
135
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
136
-			}
137
-
138
-			// validation_pattern
139
-			if(!empty($args['validation_pattern'])){
140
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
141
-			}
142
-
143
-			// step (for numbers)
144
-			if(!empty($args['step'])){
145
-				$output .= ' step="'.$args['step'].'" ';
146
-			}
147
-
148
-			// required
149
-			if(!empty($args['required'])){
150
-				$output .= ' required ';
151
-			}
152
-
153
-			// class
154
-			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
155
-			$output .= ' class="form-control '.$class.'" ';
156
-
157
-			// data-attributes
158
-			$output .= AUI_Component_Helper::data_attributes($args);
159
-
160
-			// extra attributes
161
-			if(!empty($args['extra_attributes'])){
162
-				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
163
-			}
164
-
165
-			// close
166
-			$output .= ' >';
167
-
168
-
169
-			// label
170
-			if(!empty($args['label'])){
171
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
172
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
173
-				$label = self::label( $label_args, $type );
174
-			}
175
-
176
-			// help text
177
-			if(!empty($args['help_text'])){
178
-				$help_text = AUI_Component_Helper::help_text($args['help_text']);
179
-			}
180
-
181
-
182
-			// set help text in the correct possition
183
-			if($label_after){
184
-				$output .= $label . $help_text;
185
-			}
186
-
187
-			// some input types need a separate wrap
188
-			if($type == 'file') {
189
-				$output = self::wrap( array(
190
-					'content' => $output,
191
-					'class'   => 'form-group custom-file'
192
-				) );
193
-			}elseif($type == 'checkbox'){
194
-				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
195
-				$output = self::wrap( array(
196
-					'content' => $output,
197
-					'class'   => 'custom-control '.$wrap_class
198
-				) );
199
-
200
-				if($args['label_type']=='horizontal'){
201
-					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
202
-				}
203
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
204
-
205
-
206
-				// allow password field to toggle view
207
-				$args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
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_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
36
+            'help_text'  => '',
37
+            'validation_text'   => '',
38
+            'validation_pattern' => '',
39
+            'no_wrap'    => false,
40
+            'input_group_right' => '',
41
+            'input_group_left' => '',
42
+            'input_group_right_inside' => false, // forces the input group inside the input
43
+            'input_group_left_inside' => false, // forces the input group inside the input
44
+            'step'       => '',
45
+            'switch'     => false, // to show checkbox as a switch
46
+            'checked'   => false, // set a checkbox or radio as selected
47
+            'password_toggle' => true, // toggle view/hide password
48
+            'element_require'   => '', // [%element_id%] == "1"
49
+            'extra_attributes'  => array(), // an array of extra attributes
50
+            'wrap_attributes' => array()
51
+        );
52
+
53
+        /**
54
+         * Parse incoming $args into an array and merge it with $defaults
55
+         */
56
+        $args   = wp_parse_args( $args, $defaults );
57
+        $output = '';
58
+        if ( ! empty( $args['type'] ) ) {
59
+            // hidden label option needs to be empty
60
+            $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
61
+
62
+            $type = sanitize_html_class( $args['type'] );
63
+
64
+            $help_text = '';
65
+            $label = '';
66
+            $label_after = $args['label_after'];
67
+            $label_args = array(
68
+                'title'=> $args['label'],
69
+                'for'=> $args['id'],
70
+                'class' => $args['label_class']." ",
71
+                'label_type' => $args['label_type']
72
+            );
73
+
74
+            // floating labels need label after
75
+            if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
76
+                $label_after = true;
77
+                $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
78
+            }
79
+
80
+            // Some special sauce for files
81
+            if($type=='file' ){
82
+                $label_after = true; // if type file we need the label after
83
+                $args['class'] .= ' custom-file-input ';
84
+            }elseif($type=='checkbox'){
85
+                $label_after = true; // if type file we need the label after
86
+                $args['class'] .= ' custom-control-input ';
87
+            }elseif($type=='datepicker' || $type=='timepicker'){
88
+                $type = 'text';
89
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
90
+                $args['class'] .= ' bg-initial ';
91
+
92
+                $args['extra_attributes']['data-aui-init'] = 'flatpickr';
93
+                // enqueue the script
94
+                $aui_settings = AyeCode_UI_Settings::instance();
95
+                $aui_settings->enqueue_flatpickr();
96
+            }
97
+
98
+
99
+            // open/type
100
+            $output .= '<input type="' . $type . '" ';
101
+
102
+            // name
103
+            if(!empty($args['name'])){
104
+                $output .= ' name="'.esc_attr($args['name']).'" ';
105
+            }
106
+
107
+            // id
108
+            if(!empty($args['id'])){
109
+                $output .= ' id="'.sanitize_html_class($args['id']).'" ';
110
+            }
111
+
112
+            // placeholder
113
+            if(isset($args['placeholder']) && '' != $args['placeholder'] ){
114
+                $output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
115
+            }
116
+
117
+            // title
118
+            if(!empty($args['title'])){
119
+                $output .= ' title="'.esc_attr($args['title']).'" ';
120
+            }
121
+
122
+            // value
123
+            if(!empty($args['value'])){
124
+                $output .= AUI_Component_Helper::value($args['value']);
125
+            }
126
+
127
+            // checked, for radio and checkboxes
128
+            if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
129
+                $output .= ' checked ';
130
+            }
131
+
132
+            // validation text
133
+            if(!empty($args['validation_text'])){
134
+                $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
135
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
136
+            }
137
+
138
+            // validation_pattern
139
+            if(!empty($args['validation_pattern'])){
140
+                $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
141
+            }
142
+
143
+            // step (for numbers)
144
+            if(!empty($args['step'])){
145
+                $output .= ' step="'.$args['step'].'" ';
146
+            }
147
+
148
+            // required
149
+            if(!empty($args['required'])){
150
+                $output .= ' required ';
151
+            }
152
+
153
+            // class
154
+            $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
155
+            $output .= ' class="form-control '.$class.'" ';
156
+
157
+            // data-attributes
158
+            $output .= AUI_Component_Helper::data_attributes($args);
159
+
160
+            // extra attributes
161
+            if(!empty($args['extra_attributes'])){
162
+                $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
163
+            }
164
+
165
+            // close
166
+            $output .= ' >';
167
+
168
+
169
+            // label
170
+            if(!empty($args['label'])){
171
+                if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
172
+                elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
173
+                $label = self::label( $label_args, $type );
174
+            }
175
+
176
+            // help text
177
+            if(!empty($args['help_text'])){
178
+                $help_text = AUI_Component_Helper::help_text($args['help_text']);
179
+            }
180
+
181
+
182
+            // set help text in the correct possition
183
+            if($label_after){
184
+                $output .= $label . $help_text;
185
+            }
186
+
187
+            // some input types need a separate wrap
188
+            if($type == 'file') {
189
+                $output = self::wrap( array(
190
+                    'content' => $output,
191
+                    'class'   => 'form-group custom-file'
192
+                ) );
193
+            }elseif($type == 'checkbox'){
194
+                $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
195
+                $output = self::wrap( array(
196
+                    'content' => $output,
197
+                    'class'   => 'custom-control '.$wrap_class
198
+                ) );
199
+
200
+                if($args['label_type']=='horizontal'){
201
+                    $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
202
+                }
203
+            }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
204
+
205
+
206
+                // allow password field to toggle view
207
+                $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
208 208
 onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\');
209 209
 var $eli = jQuery(this).parent().parent().find(\'input\');
210 210
 if($el.hasClass(\'fa-eye\'))
211 211
 {$eli.attr(\'type\',\'text\');}
212 212
 else{$eli.attr(\'type\',\'password\');}"
213 213
 ><i class="far fa-fw fa-eye-slash"></i></span>';
214
-			}
215
-
216
-			// input group wraps
217
-			if($args['input_group_left'] || $args['input_group_right']){
218
-				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
219
-				if($args['input_group_left']){
220
-					$output = self::wrap( array(
221
-						'content' => $output,
222
-						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
223
-						'input_group_left' => $args['input_group_left'],
224
-						'input_group_left_inside'    => $args['input_group_left_inside']
225
-					) );
226
-				}
227
-				if($args['input_group_right']){
228
-					$output = self::wrap( array(
229
-						'content' => $output,
230
-						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
231
-						'input_group_right' => $args['input_group_right'],
232
-						'input_group_right_inside'    => $args['input_group_right_inside']
233
-					) );
234
-				}
235
-
236
-			}
237
-
238
-			if(!$label_after){
239
-				$output .= $help_text;
240
-			}
241
-
242
-
243
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
244
-				$output = self::wrap( array(
245
-					'content' => $output,
246
-					'class'   => 'col-sm-10',
247
-				) );
248
-			}
249
-
250
-			if(!$label_after){
251
-				$output = $label . $output;
252
-			}
253
-
254
-			// wrap
255
-			if ( ! $args['no_wrap'] ) {
256
-				$form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
257
-				$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
258
-				$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
259
-				$output = self::wrap(array(
260
-					'content' => $output,
261
-					'class'   => $wrap_class,
262
-					'element_require'   => $args['element_require'],
263
-					'argument_id'  => $args['id'],
264
-					'wrap_attributes' => $args['wrap_attributes'],
265
-				));
266
-			}
267
-		}
268
-
269
-		return $output;
270
-	}
271
-
272
-	/**
273
-	 * Build the component.
274
-	 *
275
-	 * @param array $args
276
-	 *
277
-	 * @return string The rendered component.
278
-	 */
279
-	public static function textarea($args = array()){
280
-		$defaults = array(
281
-			'name'       => '',
282
-			'class'      => '',
283
-			'wrap_class' => '',
284
-			'id'         => '',
285
-			'placeholder'=> '',
286
-			'title'      => '',
287
-			'value'      => '',
288
-			'required'   => false,
289
-			'label'      => '',
290
-			'label_after'=> false,
291
-			'label_class'      => '',
292
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
293
-			'help_text'  => '',
294
-			'validation_text'   => '',
295
-			'validation_pattern' => '',
296
-			'no_wrap'    => false,
297
-			'rows'      => '',
298
-			'wysiwyg'   => false,
299
-			'allow_tags' => false, // Allow HTML tags
300
-			'element_require'   => '', // [%element_id%] == "1"
301
-			'extra_attributes'  => array(), // an array of extra attributes
302
-			'wrap_attributes'   => array(),
303
-		);
304
-
305
-		/**
306
-		 * Parse incoming $args into an array and merge it with $defaults
307
-		 */
308
-		$args   = wp_parse_args( $args, $defaults );
309
-		$output = '';
310
-
311
-		// hidden label option needs to be empty
312
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
313
-
314
-		// floating labels don't work with wysiwyg so set it as top
315
-		if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
316
-			$args['label_type'] = 'top';
317
-		}
318
-
319
-		$label_after = $args['label_after'];
320
-
321
-		// floating labels need label after
322
-		if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
323
-			$label_after = true;
324
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
325
-		}
326
-
327
-		// label
328
-		if(!empty($args['label']) && is_array($args['label'])){
329
-		}elseif(!empty($args['label']) && !$label_after){
330
-			$label_args = array(
331
-				'title'=> $args['label'],
332
-				'for'=> $args['id'],
333
-				'class' => $args['label_class']." ",
334
-				'label_type' => $args['label_type']
335
-			);
336
-			$output .= self::label( $label_args );
337
-		}
338
-
339
-		// maybe horizontal label
340
-		if($args['label_type']=='horizontal'){
341
-			$output .= '<div class="col-sm-10">';
342
-		}
343
-
344
-		if(!empty($args['wysiwyg'])){
345
-			ob_start();
346
-			$content = $args['value'];
347
-			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
348
-			$settings = array(
349
-				'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
350
-				'quicktags'     => false,
351
-				'media_buttons' => false,
352
-				'editor_class'  => 'form-control',
353
-				'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
354
-				'teeny'         => true,
355
-			);
356
-
357
-			// maybe set settings if array
358
-			if(is_array($args['wysiwyg'])){
359
-				$settings  = wp_parse_args( $args['wysiwyg'], $settings );
360
-			}
361
-
362
-			wp_editor( $content, $editor_id, $settings );
363
-			$output .= ob_get_clean();
364
-		}else{
365
-
366
-			// open
367
-			$output .= '<textarea ';
368
-
369
-			// name
370
-			if(!empty($args['name'])){
371
-				$output .= ' name="'.esc_attr($args['name']).'" ';
372
-			}
373
-
374
-			// id
375
-			if(!empty($args['id'])){
376
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
377
-			}
378
-
379
-			// placeholder
380
-			if(isset($args['placeholder']) && '' != $args['placeholder']){
381
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
382
-			}
383
-
384
-			// title
385
-			if(!empty($args['title'])){
386
-				$output .= ' title="'.esc_attr($args['title']).'" ';
387
-			}
388
-
389
-			// validation text
390
-			if(!empty($args['validation_text'])){
391
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
392
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
393
-			}
394
-
395
-			// validation_pattern
396
-			if(!empty($args['validation_pattern'])){
397
-				$output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
398
-			}
399
-
400
-			// required
401
-			if(!empty($args['required'])){
402
-				$output .= ' required ';
403
-			}
404
-
405
-			// rows
406
-			if(!empty($args['rows'])){
407
-				$output .= ' rows="'.absint($args['rows']).'" ';
408
-			}
409
-
410
-
411
-			// class
412
-			$class = !empty($args['class']) ? $args['class'] : '';
413
-			$output .= ' class="form-control '.$class.'" ';
414
-
415
-			// extra attributes
416
-			if(!empty($args['extra_attributes'])){
417
-				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
418
-			}
419
-
420
-			// close tag
421
-			$output .= ' >';
422
-
423
-			// value
424
-			if ( ! empty( $args['value'] ) ) {
425
-				if ( ! empty( $args['allow_tags'] ) ) {
426
-					$output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
427
-				} else {
428
-					$output .= sanitize_textarea_field( $args['value'] );
429
-				}
430
-			}
431
-
432
-			// closing tag
433
-			$output .= '</textarea>';
434
-
435
-		}
436
-
437
-		if(!empty($args['label']) && $label_after){
438
-			$label_args = array(
439
-				'title'=> $args['label'],
440
-				'for'=> $args['id'],
441
-				'class' => $args['label_class']." ",
442
-				'label_type' => $args['label_type']
443
-			);
444
-			$output .= self::label( $label_args );
445
-		}
446
-
447
-		// help text
448
-		if(!empty($args['help_text'])){
449
-			$output .= AUI_Component_Helper::help_text($args['help_text']);
450
-		}
451
-
452
-		// maybe horizontal label
453
-		if($args['label_type']=='horizontal'){
454
-			$output .= '</div>';
455
-		}
456
-
457
-
458
-		// wrap
459
-		if(!$args['no_wrap']){
460
-			$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
461
-			$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
462
-			$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
463
-			$output = self::wrap(array(
464
-				'content' => $output,
465
-				'class'   => $wrap_class,
466
-				'element_require'   => $args['element_require'],
467
-				'argument_id'  => $args['id'],
468
-				'wrap_attributes' => $args['wrap_attributes'],
469
-			));
470
-		}
471
-
472
-
473
-		return $output;
474
-	}
475
-
476
-	public static function label($args = array(), $type = ''){
477
-		//<label for="exampleInputEmail1">Email address</label>
478
-		$defaults = array(
479
-			'title'       => 'div',
480
-			'for'      => '',
481
-			'class'      => '',
482
-			'label_type'    => '', // empty = hidden, top, horizontal
483
-		);
484
-
485
-		/**
486
-		 * Parse incoming $args into an array and merge it with $defaults
487
-		 */
488
-		$args   = wp_parse_args( $args, $defaults );
489
-		$output = '';
490
-
491
-		if($args['title']){
492
-
493
-			// maybe hide labels //@todo set a global option for visibility class
494
-			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
495
-				$class = $args['class'];
496
-			}else{
497
-				$class = 'sr-only '.$args['class'];
498
-			}
499
-
500
-			// maybe horizontal
501
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
502
-				$class .= ' col-sm-2 col-form-label';
503
-			}
504
-
505
-			// open
506
-			$output .= '<label ';
507
-
508
-			// for
509
-			if(!empty($args['for'])){
510
-				$output .= ' for="'.esc_attr($args['for']).'" ';
511
-			}
512
-
513
-			// class
514
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
515
-			$output .= ' class="'.$class.'" ';
516
-
517
-			// close
518
-			$output .= '>';
519
-
520
-
521
-			// title, don't escape fully as can contain html
522
-			if(!empty($args['title'])){
523
-				$output .= wp_kses_post($args['title']);
524
-			}
525
-
526
-			// close wrap
527
-			$output .= '</label>';
528
-
529
-
530
-		}
531
-
532
-
533
-		return $output;
534
-	}
535
-
536
-	/**
537
-	 * Wrap some content in a HTML wrapper.
538
-	 *
539
-	 * @param array $args
540
-	 *
541
-	 * @return string
542
-	 */
543
-	public static function wrap($args = array()){
544
-		$defaults = array(
545
-			'type'       => 'div',
546
-			'class'      => 'form-group',
547
-			'content'   => '',
548
-			'input_group_left' => '',
549
-			'input_group_right' => '',
550
-			'input_group_left_inside' => false,
551
-			'input_group_right_inside' => false,
552
-			'element_require'   => '',
553
-			'argument_id'   => '',
554
-			'wrap_attributes' => array()
555
-		);
556
-
557
-		/**
558
-		 * Parse incoming $args into an array and merge it with $defaults
559
-		 */
560
-		$args   = wp_parse_args( $args, $defaults );
561
-		$output = '';
562
-		if($args['type']){
563
-
564
-			// open
565
-			$output .= '<'.sanitize_html_class($args['type']);
566
-
567
-			// element require
568
-			if(!empty($args['element_require'])){
569
-				$output .= AUI_Component_Helper::element_require($args['element_require']);
570
-				$args['class'] .= " aui-conditional-field";
571
-			}
572
-
573
-			// argument_id
574
-			if( !empty($args['argument_id']) ){
575
-				$output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
576
-			}
577
-
578
-			// class
579
-			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
580
-			$output .= ' class="'.$class.'" ';
581
-
582
-			// Attributes
583
-			if ( ! empty( $args['wrap_attributes'] ) ) {
584
-				$output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
585
-			}
586
-
587
-			// close wrap
588
-			$output .= ' >';
589
-
590
-
591
-			// Input group left
592
-			if(!empty($args['input_group_left'])){
593
-				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
594
-				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
595
-				$output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
596
-			}
597
-
598
-			// content
599
-			$output .= $args['content'];
600
-
601
-			// Input group right
602
-			if(!empty($args['input_group_right'])){
603
-				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
604
-				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
605
-				$output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
606
-			}
607
-
608
-
609
-			// close wrap
610
-			$output .= '</'.sanitize_html_class($args['type']).'>';
611
-
612
-
613
-		}else{
614
-			$output = $args['content'];
615
-		}
616
-
617
-		return $output;
618
-	}
619
-
620
-	/**
621
-	 * Build the component.
622
-	 *
623
-	 * @param array $args
624
-	 *
625
-	 * @return string The rendered component.
626
-	 */
627
-	public static function select($args = array()){
628
-		$defaults = array(
629
-			'class'      => '',
630
-			'wrap_class' => '',
631
-			'id'         => '',
632
-			'title'      => '',
633
-			'value'      => '', // can be an array or a string
634
-			'required'   => false,
635
-			'label'      => '',
636
-			'label_after'=> false,
637
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
638
-			'label_class'      => '',
639
-			'help_text'  => '',
640
-			'placeholder'=> '',
641
-			'options'    => array(), // array or string
642
-			'icon'       => '',
643
-			'multiple'   => false,
644
-			'select2'    => false,
645
-			'no_wrap'    => false,
646
-			'element_require'   => '', // [%element_id%] == "1"
647
-			'extra_attributes'  => array(), // an array of extra attributes
648
-			'wrap_attributes'   => array(),
649
-		);
650
-
651
-		/**
652
-		 * Parse incoming $args into an array and merge it with $defaults
653
-		 */
654
-		$args   = wp_parse_args( $args, $defaults );
655
-		$output = '';
656
-
657
-		// for now lets hide floating labels
658
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
659
-
660
-		// hidden label option needs to be empty
661
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
662
-
663
-
664
-		$label_after = $args['label_after'];
665
-
666
-		// floating labels need label after
667
-		if( $args['label_type'] == 'floating' ){
668
-			$label_after = true;
669
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
670
-		}
671
-
672
-		// Maybe setup select2
673
-		$is_select2 = false;
674
-		if(!empty($args['select2'])){
675
-			$args['class'] .= ' aui-select2';
676
-			$is_select2 = true;
677
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
678
-			$is_select2 = true;
679
-		}
680
-
681
-		// select2 tags
682
-		if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
683
-			$args['data-tags'] = 'true';
684
-			$args['data-token-separators'] = "[',']";
685
-			$args['multiple'] = true;
686
-		}
687
-
688
-		// select2 placeholder
689
-		if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){
690
-			$args['data-placeholder'] = esc_attr($args['placeholder']);
691
-			$args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
692
-		}
693
-
694
-		// label
695
-		if(!empty($args['label']) && is_array($args['label'])){
696
-		}elseif(!empty($args['label']) && !$label_after){
697
-			$label_args = array(
698
-				'title'=> $args['label'],
699
-				'for'=> $args['id'],
700
-				'class' => $args['label_class']." ",
701
-				'label_type' => $args['label_type']
702
-			);
703
-			$output .= self::label($label_args);
704
-		}
705
-
706
-		// maybe horizontal label
707
-		if($args['label_type']=='horizontal'){
708
-			$output .= '<div class="col-sm-10">';
709
-		}
710
-
711
-		// Set hidden input to save empty value for multiselect.
712
-		if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
713
-			$output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>';
714
-		}
715
-
716
-		// open/type
717
-		$output .= '<select ';
718
-
719
-		// style
720
-		if($is_select2){
721
-			$output .= " style='width:100%;' ";
722
-		}
723
-
724
-		// element require
725
-		if(!empty($args['element_require'])){
726
-			$output .= AUI_Component_Helper::element_require($args['element_require']);
727
-			$args['class'] .= " aui-conditional-field";
728
-		}
729
-
730
-		// class
731
-		$class = !empty($args['class']) ? $args['class'] : '';
732
-		$output .= AUI_Component_Helper::class_attr('custom-select '.$class);
733
-
734
-		// name
735
-		if(!empty($args['name'])){
736
-			$output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
737
-		}
738
-
739
-		// id
740
-		if(!empty($args['id'])){
741
-			$output .= AUI_Component_Helper::id($args['id']);
742
-		}
743
-
744
-		// title
745
-		if(!empty($args['title'])){
746
-			$output .= AUI_Component_Helper::title($args['title']);
747
-		}
748
-
749
-		// data-attributes
750
-		$output .= AUI_Component_Helper::data_attributes($args);
751
-
752
-		// aria-attributes
753
-		$output .= AUI_Component_Helper::aria_attributes($args);
754
-
755
-		// extra attributes
756
-		if(!empty($args['extra_attributes'])){
757
-			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
758
-		}
759
-
760
-		// required
761
-		if(!empty($args['required'])){
762
-			$output .= ' required ';
763
-		}
764
-
765
-		// multiple
766
-		if(!empty($args['multiple'])){
767
-			$output .= ' multiple ';
768
-		}
769
-
770
-		// close opening tag
771
-		$output .= ' >';
772
-
773
-		// placeholder
774
-		if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){
775
-			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
776
-		}elseif($is_select2 && !empty($args['placeholder'])){
777
-			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
778
-		}
779
-
780
-		// Options
781
-		if(!empty($args['options'])){
782
-
783
-			if(!is_array($args['options'])){
784
-				$output .= $args['options']; // not the preferred way but an option
785
-			}else{
786
-				foreach($args['options'] as $val => $name){
787
-					$selected = '';
788
-					if(is_array($name)){
789
-						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
790
-							$option_label = isset($name['label']) ? $name['label'] : '';
791
-
792
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
793
-						} else {
794
-							$option_label = isset($name['label']) ? $name['label'] : '';
795
-							$option_value = isset($name['value']) ? $name['value'] : '';
796
-							if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){
797
-								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
798
-							} elseif(!empty($args['value'])) {
799
-								$selected = selected($option_value,stripslashes_deep($args['value']), false);
800
-							}
801
-
802
-							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
803
-						}
804
-					}else{
805
-						if(!empty($args['value'])){
806
-							if(is_array($args['value'])){
807
-								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
808
-							} elseif(!empty($args['value'])) {
809
-								$selected = selected( $args['value'], $val, false);
810
-							}
811
-						}
812
-						$output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
813
-					}
814
-				}
815
-			}
816
-
817
-		}
818
-
819
-		// closing tag
820
-		$output .= '</select>';
821
-
822
-		if(!empty($args['label']) && $label_after){
823
-			$label_args = array(
824
-				'title'=> $args['label'],
825
-				'for'=> $args['id'],
826
-				'class' => $args['label_class']." ",
827
-				'label_type' => $args['label_type']
828
-			);
829
-			$output .= self::label($label_args);
830
-		}
831
-
832
-		// help text
833
-		if(!empty($args['help_text'])){
834
-			$output .= AUI_Component_Helper::help_text($args['help_text']);
835
-		}
836
-
837
-		// maybe horizontal label
838
-		if($args['label_type']=='horizontal'){
839
-			$output .= '</div>';
840
-		}
841
-
842
-
843
-		// wrap
844
-		if(!$args['no_wrap']){
845
-			$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
846
-			$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
847
-			$output = self::wrap(array(
848
-				'content' => $output,
849
-				'class'   => $wrap_class,
850
-				'element_require'   => $args['element_require'],
851
-				'argument_id'  => $args['id'],
852
-				'wrap_attributes' => $args['wrap_attributes'],
853
-			));
854
-		}
855
-
856
-
857
-		return $output;
858
-	}
859
-
860
-	/**
861
-	 * Build the component.
862
-	 *
863
-	 * @param array $args
864
-	 *
865
-	 * @return string The rendered component.
866
-	 */
867
-	public static function radio($args = array()){
868
-		$defaults = array(
869
-			'class'      => '',
870
-			'wrap_class' => '',
871
-			'id'         => '',
872
-			'title'      => '',
873
-			'horizontal' => false, // sets the lable horizontal
874
-			'value'      => '',
875
-			'label'      => '',
876
-			'label_class'=> '',
877
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
878
-			'help_text'  => '',
879
-			'inline'     => true,
880
-			'required'   => false,
881
-			'options'    => array(),
882
-			'icon'       => '',
883
-			'no_wrap'    => false,
884
-			'element_require'   => '', // [%element_id%] == "1"
885
-			'extra_attributes'  => array(), // an array of extra attributes
886
-			'wrap_attributes'   => array()
887
-		);
888
-
889
-		/**
890
-		 * Parse incoming $args into an array and merge it with $defaults
891
-		 */
892
-		$args   = wp_parse_args( $args, $defaults );
893
-
894
-		// for now lets use horizontal for floating
895
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';}
896
-
897
-		$label_args = array(
898
-			'title'=> $args['label'],
899
-			'class' => $args['label_class']." pt-0 ",
900
-			'label_type' => $args['label_type']
901
-		);
902
-
903
-		$output = '';
904
-
905
-
906
-
907
-		// label before
908
-		if(!empty($args['label'])){
909
-			$output .= self::label( $label_args, 'radio' );
910
-		}
911
-
912
-		// maybe horizontal label
913
-		if($args['label_type']=='horizontal'){
914
-			$output .= '<div class="col-sm-10">';
915
-		}
916
-
917
-		if(!empty($args['options'])){
918
-			$count = 0;
919
-			foreach($args['options'] as $value => $label){
920
-				$option_args = $args;
921
-				$option_args['value'] = $value;
922
-				$option_args['label'] = $label;
923
-				$option_args['checked'] = $value == $args['value'] ? true : false;
924
-				$output .= self::radio_option($option_args,$count);
925
-				$count++;
926
-			}
927
-		}
928
-
929
-		// help text
930
-		$help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
931
-		$output .= $help_text;
932
-
933
-		// maybe horizontal label
934
-		if($args['label_type']=='horizontal'){
935
-			$output .= '</div>';
936
-		}
937
-
938
-		// wrap
939
-		$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
940
-		$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
941
-		$output = self::wrap(array(
942
-			'content' => $output,
943
-			'class'   => $wrap_class,
944
-			'element_require'   => $args['element_require'],
945
-			'argument_id'  => $args['id'],
946
-			'wrap_attributes' => $args['wrap_attributes'],
947
-		));
948
-
949
-
950
-		return $output;
951
-	}
952
-
953
-	/**
954
-	 * Build the component.
955
-	 *
956
-	 * @param array $args
957
-	 *
958
-	 * @return string The rendered component.
959
-	 */
960
-	public static function radio_option($args = array(),$count = ''){
961
-		$defaults = array(
962
-			'class'      => '',
963
-			'id'         => '',
964
-			'title'      => '',
965
-			'value'      => '',
966
-			'required'   => false,
967
-			'inline'     => true,
968
-			'label'      => '',
969
-			'options'    => array(),
970
-			'icon'       => '',
971
-			'no_wrap'    => false,
972
-			'extra_attributes'  => array() // an array of extra attributes
973
-		);
974
-
975
-		/**
976
-		 * Parse incoming $args into an array and merge it with $defaults
977
-		 */
978
-		$args   = wp_parse_args( $args, $defaults );
979
-
980
-		$output = '';
981
-
982
-		// open/type
983
-		$output .= '<input type="radio"';
984
-
985
-		// class
986
-		$output .= ' class="form-check-input" ';
987
-
988
-		// name
989
-		if(!empty($args['name'])){
990
-			$output .= AUI_Component_Helper::name($args['name']);
991
-		}
992
-
993
-		// id
994
-		if(!empty($args['id'])){
995
-			$output .= AUI_Component_Helper::id($args['id'].$count);
996
-		}
997
-
998
-		// title
999
-		if(!empty($args['title'])){
1000
-			$output .= AUI_Component_Helper::title($args['title']);
1001
-		}
1002
-
1003
-		// value
1004
-		if(isset($args['value'])){
1005
-			$output .= AUI_Component_Helper::value($args['value']);
1006
-		}
1007
-
1008
-		// checked, for radio and checkboxes
1009
-		if( $args['checked'] ){
1010
-			$output .= ' checked ';
1011
-		}
1012
-
1013
-		// data-attributes
1014
-		$output .= AUI_Component_Helper::data_attributes($args);
1015
-
1016
-		// aria-attributes
1017
-		$output .= AUI_Component_Helper::aria_attributes($args);
1018
-
1019
-		// extra attributes
1020
-		if(!empty($args['extra_attributes'])){
1021
-			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
1022
-		}
1023
-
1024
-		// required
1025
-		if(!empty($args['required'])){
1026
-			$output .= ' required ';
1027
-		}
1028
-
1029
-		// close opening tag
1030
-		$output .= ' >';
1031
-
1032
-		// label
1033
-		if(!empty($args['label']) && is_array($args['label'])){
1034
-		}elseif(!empty($args['label'])){
1035
-			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
1036
-		}
1037
-
1038
-		// wrap
1039
-		if ( ! $args['no_wrap'] ) {
1040
-			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1041
-
1042
-			// Unique wrap class
1043
-			$uniq_class = 'fwrap';
1044
-			if ( ! empty( $args['name'] ) ) {
1045
-				$uniq_class .= '-' . $args['name'];
1046
-			} else if ( ! empty( $args['id'] ) ) {
1047
-				$uniq_class .= '-' . $args['id'];
1048
-			}
1049
-
1050
-			if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1051
-				$uniq_class .= '-' . $args['value'];
1052
-			} else {
1053
-				$uniq_class .= '-' . $count;
1054
-			}
1055
-			$wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1056
-
1057
-			$output = self::wrap(array(
1058
-				'content' => $output,
1059
-				'class' => $wrap_class
1060
-			));
1061
-		}
1062
-
1063
-		return $output;
1064
-	}
214
+            }
215
+
216
+            // input group wraps
217
+            if($args['input_group_left'] || $args['input_group_right']){
218
+                $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
219
+                if($args['input_group_left']){
220
+                    $output = self::wrap( array(
221
+                        'content' => $output,
222
+                        'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
223
+                        'input_group_left' => $args['input_group_left'],
224
+                        'input_group_left_inside'    => $args['input_group_left_inside']
225
+                    ) );
226
+                }
227
+                if($args['input_group_right']){
228
+                    $output = self::wrap( array(
229
+                        'content' => $output,
230
+                        'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
231
+                        'input_group_right' => $args['input_group_right'],
232
+                        'input_group_right_inside'    => $args['input_group_right_inside']
233
+                    ) );
234
+                }
235
+
236
+            }
237
+
238
+            if(!$label_after){
239
+                $output .= $help_text;
240
+            }
241
+
242
+
243
+            if($args['label_type']=='horizontal' && $type != 'checkbox'){
244
+                $output = self::wrap( array(
245
+                    'content' => $output,
246
+                    'class'   => 'col-sm-10',
247
+                ) );
248
+            }
249
+
250
+            if(!$label_after){
251
+                $output = $label . $output;
252
+            }
253
+
254
+            // wrap
255
+            if ( ! $args['no_wrap'] ) {
256
+                $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
257
+                $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
258
+                $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
259
+                $output = self::wrap(array(
260
+                    'content' => $output,
261
+                    'class'   => $wrap_class,
262
+                    'element_require'   => $args['element_require'],
263
+                    'argument_id'  => $args['id'],
264
+                    'wrap_attributes' => $args['wrap_attributes'],
265
+                ));
266
+            }
267
+        }
268
+
269
+        return $output;
270
+    }
271
+
272
+    /**
273
+     * Build the component.
274
+     *
275
+     * @param array $args
276
+     *
277
+     * @return string The rendered component.
278
+     */
279
+    public static function textarea($args = array()){
280
+        $defaults = array(
281
+            'name'       => '',
282
+            'class'      => '',
283
+            'wrap_class' => '',
284
+            'id'         => '',
285
+            'placeholder'=> '',
286
+            'title'      => '',
287
+            'value'      => '',
288
+            'required'   => false,
289
+            'label'      => '',
290
+            'label_after'=> false,
291
+            'label_class'      => '',
292
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
293
+            'help_text'  => '',
294
+            'validation_text'   => '',
295
+            'validation_pattern' => '',
296
+            'no_wrap'    => false,
297
+            'rows'      => '',
298
+            'wysiwyg'   => false,
299
+            'allow_tags' => false, // Allow HTML tags
300
+            'element_require'   => '', // [%element_id%] == "1"
301
+            'extra_attributes'  => array(), // an array of extra attributes
302
+            'wrap_attributes'   => array(),
303
+        );
304
+
305
+        /**
306
+         * Parse incoming $args into an array and merge it with $defaults
307
+         */
308
+        $args   = wp_parse_args( $args, $defaults );
309
+        $output = '';
310
+
311
+        // hidden label option needs to be empty
312
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
313
+
314
+        // floating labels don't work with wysiwyg so set it as top
315
+        if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
316
+            $args['label_type'] = 'top';
317
+        }
318
+
319
+        $label_after = $args['label_after'];
320
+
321
+        // floating labels need label after
322
+        if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
323
+            $label_after = true;
324
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
325
+        }
326
+
327
+        // label
328
+        if(!empty($args['label']) && is_array($args['label'])){
329
+        }elseif(!empty($args['label']) && !$label_after){
330
+            $label_args = array(
331
+                'title'=> $args['label'],
332
+                'for'=> $args['id'],
333
+                'class' => $args['label_class']." ",
334
+                'label_type' => $args['label_type']
335
+            );
336
+            $output .= self::label( $label_args );
337
+        }
338
+
339
+        // maybe horizontal label
340
+        if($args['label_type']=='horizontal'){
341
+            $output .= '<div class="col-sm-10">';
342
+        }
343
+
344
+        if(!empty($args['wysiwyg'])){
345
+            ob_start();
346
+            $content = $args['value'];
347
+            $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
348
+            $settings = array(
349
+                'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
350
+                'quicktags'     => false,
351
+                'media_buttons' => false,
352
+                'editor_class'  => 'form-control',
353
+                'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
354
+                'teeny'         => true,
355
+            );
356
+
357
+            // maybe set settings if array
358
+            if(is_array($args['wysiwyg'])){
359
+                $settings  = wp_parse_args( $args['wysiwyg'], $settings );
360
+            }
361
+
362
+            wp_editor( $content, $editor_id, $settings );
363
+            $output .= ob_get_clean();
364
+        }else{
365
+
366
+            // open
367
+            $output .= '<textarea ';
368
+
369
+            // name
370
+            if(!empty($args['name'])){
371
+                $output .= ' name="'.esc_attr($args['name']).'" ';
372
+            }
373
+
374
+            // id
375
+            if(!empty($args['id'])){
376
+                $output .= ' id="'.sanitize_html_class($args['id']).'" ';
377
+            }
378
+
379
+            // placeholder
380
+            if(isset($args['placeholder']) && '' != $args['placeholder']){
381
+                $output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
382
+            }
383
+
384
+            // title
385
+            if(!empty($args['title'])){
386
+                $output .= ' title="'.esc_attr($args['title']).'" ';
387
+            }
388
+
389
+            // validation text
390
+            if(!empty($args['validation_text'])){
391
+                $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
392
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
393
+            }
394
+
395
+            // validation_pattern
396
+            if(!empty($args['validation_pattern'])){
397
+                $output .= ' pattern="' . esc_attr( $args['validation_pattern'] ) . '" ';
398
+            }
399
+
400
+            // required
401
+            if(!empty($args['required'])){
402
+                $output .= ' required ';
403
+            }
404
+
405
+            // rows
406
+            if(!empty($args['rows'])){
407
+                $output .= ' rows="'.absint($args['rows']).'" ';
408
+            }
409
+
410
+
411
+            // class
412
+            $class = !empty($args['class']) ? $args['class'] : '';
413
+            $output .= ' class="form-control '.$class.'" ';
414
+
415
+            // extra attributes
416
+            if(!empty($args['extra_attributes'])){
417
+                $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
418
+            }
419
+
420
+            // close tag
421
+            $output .= ' >';
422
+
423
+            // value
424
+            if ( ! empty( $args['value'] ) ) {
425
+                if ( ! empty( $args['allow_tags'] ) ) {
426
+                    $output .= AUI_Component_Helper::sanitize_html_field( $args['value'], $args ); // Sanitize HTML.
427
+                } else {
428
+                    $output .= sanitize_textarea_field( $args['value'] );
429
+                }
430
+            }
431
+
432
+            // closing tag
433
+            $output .= '</textarea>';
434
+
435
+        }
436
+
437
+        if(!empty($args['label']) && $label_after){
438
+            $label_args = array(
439
+                'title'=> $args['label'],
440
+                'for'=> $args['id'],
441
+                'class' => $args['label_class']." ",
442
+                'label_type' => $args['label_type']
443
+            );
444
+            $output .= self::label( $label_args );
445
+        }
446
+
447
+        // help text
448
+        if(!empty($args['help_text'])){
449
+            $output .= AUI_Component_Helper::help_text($args['help_text']);
450
+        }
451
+
452
+        // maybe horizontal label
453
+        if($args['label_type']=='horizontal'){
454
+            $output .= '</div>';
455
+        }
456
+
457
+
458
+        // wrap
459
+        if(!$args['no_wrap']){
460
+            $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
461
+            $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
462
+            $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
463
+            $output = self::wrap(array(
464
+                'content' => $output,
465
+                'class'   => $wrap_class,
466
+                'element_require'   => $args['element_require'],
467
+                'argument_id'  => $args['id'],
468
+                'wrap_attributes' => $args['wrap_attributes'],
469
+            ));
470
+        }
471
+
472
+
473
+        return $output;
474
+    }
475
+
476
+    public static function label($args = array(), $type = ''){
477
+        //<label for="exampleInputEmail1">Email address</label>
478
+        $defaults = array(
479
+            'title'       => 'div',
480
+            'for'      => '',
481
+            'class'      => '',
482
+            'label_type'    => '', // empty = hidden, top, horizontal
483
+        );
484
+
485
+        /**
486
+         * Parse incoming $args into an array and merge it with $defaults
487
+         */
488
+        $args   = wp_parse_args( $args, $defaults );
489
+        $output = '';
490
+
491
+        if($args['title']){
492
+
493
+            // maybe hide labels //@todo set a global option for visibility class
494
+            if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
495
+                $class = $args['class'];
496
+            }else{
497
+                $class = 'sr-only '.$args['class'];
498
+            }
499
+
500
+            // maybe horizontal
501
+            if($args['label_type']=='horizontal' && $type != 'checkbox'){
502
+                $class .= ' col-sm-2 col-form-label';
503
+            }
504
+
505
+            // open
506
+            $output .= '<label ';
507
+
508
+            // for
509
+            if(!empty($args['for'])){
510
+                $output .= ' for="'.esc_attr($args['for']).'" ';
511
+            }
512
+
513
+            // class
514
+            $class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
515
+            $output .= ' class="'.$class.'" ';
516
+
517
+            // close
518
+            $output .= '>';
519
+
520
+
521
+            // title, don't escape fully as can contain html
522
+            if(!empty($args['title'])){
523
+                $output .= wp_kses_post($args['title']);
524
+            }
525
+
526
+            // close wrap
527
+            $output .= '</label>';
528
+
529
+
530
+        }
531
+
532
+
533
+        return $output;
534
+    }
535
+
536
+    /**
537
+     * Wrap some content in a HTML wrapper.
538
+     *
539
+     * @param array $args
540
+     *
541
+     * @return string
542
+     */
543
+    public static function wrap($args = array()){
544
+        $defaults = array(
545
+            'type'       => 'div',
546
+            'class'      => 'form-group',
547
+            'content'   => '',
548
+            'input_group_left' => '',
549
+            'input_group_right' => '',
550
+            'input_group_left_inside' => false,
551
+            'input_group_right_inside' => false,
552
+            'element_require'   => '',
553
+            'argument_id'   => '',
554
+            'wrap_attributes' => array()
555
+        );
556
+
557
+        /**
558
+         * Parse incoming $args into an array and merge it with $defaults
559
+         */
560
+        $args   = wp_parse_args( $args, $defaults );
561
+        $output = '';
562
+        if($args['type']){
563
+
564
+            // open
565
+            $output .= '<'.sanitize_html_class($args['type']);
566
+
567
+            // element require
568
+            if(!empty($args['element_require'])){
569
+                $output .= AUI_Component_Helper::element_require($args['element_require']);
570
+                $args['class'] .= " aui-conditional-field";
571
+            }
572
+
573
+            // argument_id
574
+            if( !empty($args['argument_id']) ){
575
+                $output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
576
+            }
577
+
578
+            // class
579
+            $class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
580
+            $output .= ' class="'.$class.'" ';
581
+
582
+            // Attributes
583
+            if ( ! empty( $args['wrap_attributes'] ) ) {
584
+                $output .= AUI_Component_Helper::extra_attributes( $args['wrap_attributes'] );
585
+            }
586
+
587
+            // close wrap
588
+            $output .= ' >';
589
+
590
+
591
+            // Input group left
592
+            if(!empty($args['input_group_left'])){
593
+                $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
594
+                $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
595
+                $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
596
+            }
597
+
598
+            // content
599
+            $output .= $args['content'];
600
+
601
+            // Input group right
602
+            if(!empty($args['input_group_right'])){
603
+                $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
604
+                $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
605
+                $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
606
+            }
607
+
608
+
609
+            // close wrap
610
+            $output .= '</'.sanitize_html_class($args['type']).'>';
611
+
612
+
613
+        }else{
614
+            $output = $args['content'];
615
+        }
616
+
617
+        return $output;
618
+    }
619
+
620
+    /**
621
+     * Build the component.
622
+     *
623
+     * @param array $args
624
+     *
625
+     * @return string The rendered component.
626
+     */
627
+    public static function select($args = array()){
628
+        $defaults = array(
629
+            'class'      => '',
630
+            'wrap_class' => '',
631
+            'id'         => '',
632
+            'title'      => '',
633
+            'value'      => '', // can be an array or a string
634
+            'required'   => false,
635
+            'label'      => '',
636
+            'label_after'=> false,
637
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
638
+            'label_class'      => '',
639
+            'help_text'  => '',
640
+            'placeholder'=> '',
641
+            'options'    => array(), // array or string
642
+            'icon'       => '',
643
+            'multiple'   => false,
644
+            'select2'    => false,
645
+            'no_wrap'    => false,
646
+            'element_require'   => '', // [%element_id%] == "1"
647
+            'extra_attributes'  => array(), // an array of extra attributes
648
+            'wrap_attributes'   => array(),
649
+        );
650
+
651
+        /**
652
+         * Parse incoming $args into an array and merge it with $defaults
653
+         */
654
+        $args   = wp_parse_args( $args, $defaults );
655
+        $output = '';
656
+
657
+        // for now lets hide floating labels
658
+        if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
659
+
660
+        // hidden label option needs to be empty
661
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
662
+
663
+
664
+        $label_after = $args['label_after'];
665
+
666
+        // floating labels need label after
667
+        if( $args['label_type'] == 'floating' ){
668
+            $label_after = true;
669
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
670
+        }
671
+
672
+        // Maybe setup select2
673
+        $is_select2 = false;
674
+        if(!empty($args['select2'])){
675
+            $args['class'] .= ' aui-select2';
676
+            $is_select2 = true;
677
+        }elseif( strpos($args['class'], 'aui-select2') !== false){
678
+            $is_select2 = true;
679
+        }
680
+
681
+        // select2 tags
682
+        if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
683
+            $args['data-tags'] = 'true';
684
+            $args['data-token-separators'] = "[',']";
685
+            $args['multiple'] = true;
686
+        }
687
+
688
+        // select2 placeholder
689
+        if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){
690
+            $args['data-placeholder'] = esc_attr($args['placeholder']);
691
+            $args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
692
+        }
693
+
694
+        // label
695
+        if(!empty($args['label']) && is_array($args['label'])){
696
+        }elseif(!empty($args['label']) && !$label_after){
697
+            $label_args = array(
698
+                'title'=> $args['label'],
699
+                'for'=> $args['id'],
700
+                'class' => $args['label_class']." ",
701
+                'label_type' => $args['label_type']
702
+            );
703
+            $output .= self::label($label_args);
704
+        }
705
+
706
+        // maybe horizontal label
707
+        if($args['label_type']=='horizontal'){
708
+            $output .= '<div class="col-sm-10">';
709
+        }
710
+
711
+        // Set hidden input to save empty value for multiselect.
712
+        if ( ! empty( $args['multiple'] ) && ! empty( $args['name'] ) ) {
713
+            $output .= '<input type="hidden" ' . AUI_Component_Helper::name( $args['name'] ) . ' value=""/>';
714
+        }
715
+
716
+        // open/type
717
+        $output .= '<select ';
718
+
719
+        // style
720
+        if($is_select2){
721
+            $output .= " style='width:100%;' ";
722
+        }
723
+
724
+        // element require
725
+        if(!empty($args['element_require'])){
726
+            $output .= AUI_Component_Helper::element_require($args['element_require']);
727
+            $args['class'] .= " aui-conditional-field";
728
+        }
729
+
730
+        // class
731
+        $class = !empty($args['class']) ? $args['class'] : '';
732
+        $output .= AUI_Component_Helper::class_attr('custom-select '.$class);
733
+
734
+        // name
735
+        if(!empty($args['name'])){
736
+            $output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
737
+        }
738
+
739
+        // id
740
+        if(!empty($args['id'])){
741
+            $output .= AUI_Component_Helper::id($args['id']);
742
+        }
743
+
744
+        // title
745
+        if(!empty($args['title'])){
746
+            $output .= AUI_Component_Helper::title($args['title']);
747
+        }
748
+
749
+        // data-attributes
750
+        $output .= AUI_Component_Helper::data_attributes($args);
751
+
752
+        // aria-attributes
753
+        $output .= AUI_Component_Helper::aria_attributes($args);
754
+
755
+        // extra attributes
756
+        if(!empty($args['extra_attributes'])){
757
+            $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
758
+        }
759
+
760
+        // required
761
+        if(!empty($args['required'])){
762
+            $output .= ' required ';
763
+        }
764
+
765
+        // multiple
766
+        if(!empty($args['multiple'])){
767
+            $output .= ' multiple ';
768
+        }
769
+
770
+        // close opening tag
771
+        $output .= ' >';
772
+
773
+        // placeholder
774
+        if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){
775
+            $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
776
+        }elseif($is_select2 && !empty($args['placeholder'])){
777
+            $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
778
+        }
779
+
780
+        // Options
781
+        if(!empty($args['options'])){
782
+
783
+            if(!is_array($args['options'])){
784
+                $output .= $args['options']; // not the preferred way but an option
785
+            }else{
786
+                foreach($args['options'] as $val => $name){
787
+                    $selected = '';
788
+                    if(is_array($name)){
789
+                        if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
790
+                            $option_label = isset($name['label']) ? $name['label'] : '';
791
+
792
+                            $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
793
+                        } else {
794
+                            $option_label = isset($name['label']) ? $name['label'] : '';
795
+                            $option_value = isset($name['value']) ? $name['value'] : '';
796
+                            if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){
797
+                                $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
798
+                            } elseif(!empty($args['value'])) {
799
+                                $selected = selected($option_value,stripslashes_deep($args['value']), false);
800
+                            }
801
+
802
+                            $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
803
+                        }
804
+                    }else{
805
+                        if(!empty($args['value'])){
806
+                            if(is_array($args['value'])){
807
+                                $selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
808
+                            } elseif(!empty($args['value'])) {
809
+                                $selected = selected( $args['value'], $val, false);
810
+                            }
811
+                        }
812
+                        $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
813
+                    }
814
+                }
815
+            }
816
+
817
+        }
818
+
819
+        // closing tag
820
+        $output .= '</select>';
821
+
822
+        if(!empty($args['label']) && $label_after){
823
+            $label_args = array(
824
+                'title'=> $args['label'],
825
+                'for'=> $args['id'],
826
+                'class' => $args['label_class']." ",
827
+                'label_type' => $args['label_type']
828
+            );
829
+            $output .= self::label($label_args);
830
+        }
831
+
832
+        // help text
833
+        if(!empty($args['help_text'])){
834
+            $output .= AUI_Component_Helper::help_text($args['help_text']);
835
+        }
836
+
837
+        // maybe horizontal label
838
+        if($args['label_type']=='horizontal'){
839
+            $output .= '</div>';
840
+        }
841
+
842
+
843
+        // wrap
844
+        if(!$args['no_wrap']){
845
+            $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
846
+            $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
847
+            $output = self::wrap(array(
848
+                'content' => $output,
849
+                'class'   => $wrap_class,
850
+                'element_require'   => $args['element_require'],
851
+                'argument_id'  => $args['id'],
852
+                'wrap_attributes' => $args['wrap_attributes'],
853
+            ));
854
+        }
855
+
856
+
857
+        return $output;
858
+    }
859
+
860
+    /**
861
+     * Build the component.
862
+     *
863
+     * @param array $args
864
+     *
865
+     * @return string The rendered component.
866
+     */
867
+    public static function radio($args = array()){
868
+        $defaults = array(
869
+            'class'      => '',
870
+            'wrap_class' => '',
871
+            'id'         => '',
872
+            'title'      => '',
873
+            'horizontal' => false, // sets the lable horizontal
874
+            'value'      => '',
875
+            'label'      => '',
876
+            'label_class'=> '',
877
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
878
+            'help_text'  => '',
879
+            'inline'     => true,
880
+            'required'   => false,
881
+            'options'    => array(),
882
+            'icon'       => '',
883
+            'no_wrap'    => false,
884
+            'element_require'   => '', // [%element_id%] == "1"
885
+            'extra_attributes'  => array(), // an array of extra attributes
886
+            'wrap_attributes'   => array()
887
+        );
888
+
889
+        /**
890
+         * Parse incoming $args into an array and merge it with $defaults
891
+         */
892
+        $args   = wp_parse_args( $args, $defaults );
893
+
894
+        // for now lets use horizontal for floating
895
+        if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';}
896
+
897
+        $label_args = array(
898
+            'title'=> $args['label'],
899
+            'class' => $args['label_class']." pt-0 ",
900
+            'label_type' => $args['label_type']
901
+        );
902
+
903
+        $output = '';
904
+
905
+
906
+
907
+        // label before
908
+        if(!empty($args['label'])){
909
+            $output .= self::label( $label_args, 'radio' );
910
+        }
911
+
912
+        // maybe horizontal label
913
+        if($args['label_type']=='horizontal'){
914
+            $output .= '<div class="col-sm-10">';
915
+        }
916
+
917
+        if(!empty($args['options'])){
918
+            $count = 0;
919
+            foreach($args['options'] as $value => $label){
920
+                $option_args = $args;
921
+                $option_args['value'] = $value;
922
+                $option_args['label'] = $label;
923
+                $option_args['checked'] = $value == $args['value'] ? true : false;
924
+                $output .= self::radio_option($option_args,$count);
925
+                $count++;
926
+            }
927
+        }
928
+
929
+        // help text
930
+        $help_text = ! empty( $args['help_text'] ) ? AUI_Component_Helper::help_text( $args['help_text'] ) : '';
931
+        $output .= $help_text;
932
+
933
+        // maybe horizontal label
934
+        if($args['label_type']=='horizontal'){
935
+            $output .= '</div>';
936
+        }
937
+
938
+        // wrap
939
+        $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
940
+        $wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
941
+        $output = self::wrap(array(
942
+            'content' => $output,
943
+            'class'   => $wrap_class,
944
+            'element_require'   => $args['element_require'],
945
+            'argument_id'  => $args['id'],
946
+            'wrap_attributes' => $args['wrap_attributes'],
947
+        ));
948
+
949
+
950
+        return $output;
951
+    }
952
+
953
+    /**
954
+     * Build the component.
955
+     *
956
+     * @param array $args
957
+     *
958
+     * @return string The rendered component.
959
+     */
960
+    public static function radio_option($args = array(),$count = ''){
961
+        $defaults = array(
962
+            'class'      => '',
963
+            'id'         => '',
964
+            'title'      => '',
965
+            'value'      => '',
966
+            'required'   => false,
967
+            'inline'     => true,
968
+            'label'      => '',
969
+            'options'    => array(),
970
+            'icon'       => '',
971
+            'no_wrap'    => false,
972
+            'extra_attributes'  => array() // an array of extra attributes
973
+        );
974
+
975
+        /**
976
+         * Parse incoming $args into an array and merge it with $defaults
977
+         */
978
+        $args   = wp_parse_args( $args, $defaults );
979
+
980
+        $output = '';
981
+
982
+        // open/type
983
+        $output .= '<input type="radio"';
984
+
985
+        // class
986
+        $output .= ' class="form-check-input" ';
987
+
988
+        // name
989
+        if(!empty($args['name'])){
990
+            $output .= AUI_Component_Helper::name($args['name']);
991
+        }
992
+
993
+        // id
994
+        if(!empty($args['id'])){
995
+            $output .= AUI_Component_Helper::id($args['id'].$count);
996
+        }
997
+
998
+        // title
999
+        if(!empty($args['title'])){
1000
+            $output .= AUI_Component_Helper::title($args['title']);
1001
+        }
1002
+
1003
+        // value
1004
+        if(isset($args['value'])){
1005
+            $output .= AUI_Component_Helper::value($args['value']);
1006
+        }
1007
+
1008
+        // checked, for radio and checkboxes
1009
+        if( $args['checked'] ){
1010
+            $output .= ' checked ';
1011
+        }
1012
+
1013
+        // data-attributes
1014
+        $output .= AUI_Component_Helper::data_attributes($args);
1015
+
1016
+        // aria-attributes
1017
+        $output .= AUI_Component_Helper::aria_attributes($args);
1018
+
1019
+        // extra attributes
1020
+        if(!empty($args['extra_attributes'])){
1021
+            $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
1022
+        }
1023
+
1024
+        // required
1025
+        if(!empty($args['required'])){
1026
+            $output .= ' required ';
1027
+        }
1028
+
1029
+        // close opening tag
1030
+        $output .= ' >';
1031
+
1032
+        // label
1033
+        if(!empty($args['label']) && is_array($args['label'])){
1034
+        }elseif(!empty($args['label'])){
1035
+            $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
1036
+        }
1037
+
1038
+        // wrap
1039
+        if ( ! $args['no_wrap'] ) {
1040
+            $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1041
+
1042
+            // Unique wrap class
1043
+            $uniq_class = 'fwrap';
1044
+            if ( ! empty( $args['name'] ) ) {
1045
+                $uniq_class .= '-' . $args['name'];
1046
+            } else if ( ! empty( $args['id'] ) ) {
1047
+                $uniq_class .= '-' . $args['id'];
1048
+            }
1049
+
1050
+            if ( isset( $args['value'] ) || $args['value'] !== "" ) {
1051
+                $uniq_class .= '-' . $args['value'];
1052
+            } else {
1053
+                $uniq_class .= '-' . $count;
1054
+            }
1055
+            $wrap_class .= ' ' . sanitize_html_class( $uniq_class );
1056
+
1057
+            $output = self::wrap(array(
1058
+                'content' => $output,
1059
+                'class' => $wrap_class
1060
+            ));
1061
+        }
1062
+
1063
+        return $output;
1064
+    }
1065 1065
 
1066 1066
 }
1067 1067
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/class-aui.php 1 patch
Indentation   +227 added lines, -227 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,231 +11,231 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI {
13 13
 
14
-	/**
15
-	 * Holds the class instance.
16
-	 *
17
-	 * @since 1.0.0
18
-	 * @var null
19
-	 */
20
-	private static $instance = null;
21
-
22
-	/**
23
-	 * Holds the current AUI version number.
24
-	 *
25
-	 * @var string $ver The current version number.
26
-	 */
27
-	public static $ver = '0.1.61';
28
-
29
-	public static $options = null;
30
-
31
-	/**
32
-	 * There can be only one.
33
-	 *
34
-	 * @since 1.0.0
35
-	 * @return AUI|null
36
-	 */
37
-	public static function instance() {
38
-		if ( self::$instance == null ) {
39
-			self::$instance = new AUI();
40
-		}
41
-
42
-		return self::$instance;
43
-	}
44
-
45
-	/**
46
-	 * AUI constructor.
47
-	 *
48
-	 * @since 1.0.0
49
-	 */
50
-	private function __construct() {
51
-		if ( function_exists( "__autoload" ) ) {
52
-			spl_autoload_register( "__autoload" );
53
-		}
54
-		spl_autoload_register( array( $this, 'autoload' ) );
55
-
56
-		// load options
57
-		self::$options = get_option('aui_options');
58
-	}
59
-
60
-	/**
61
-	 * Autoload any components on the fly.
62
-	 *
63
-	 * @since 1.0.0
64
-	 *
65
-	 * @param $classname
66
-	 */
67
-	private function autoload( $classname ) {
68
-		$class     = str_replace( '_', '-', strtolower( $classname ) );
69
-		$file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php';
70
-		if ( $file_path && is_readable( $file_path ) ) {
71
-			include_once( $file_path );
72
-		}
73
-	}
74
-
75
-	/**
76
-	 * Get the AUI options.
77
-	 *
78
-	 * @param $option
79
-	 *
80
-	 * @return string|void
81
-	 */
82
-	public function get_option( $option ){
83
-		$result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : '';
84
-
85
-		if ( ! $result && $option) {
86
-			if( $option == 'color_primary' ){
87
-				$result = AUI_PRIMARY_COLOR;
88
-			}elseif( $option == 'color_secondary' ){
89
-				$result = AUI_SECONDARY_COLOR;
90
-			}
91
-		}
92
-		return $result;
93
-	}
94
-
95
-	public function render( $items = array() ) {
96
-		$output = '';
97
-
98
-		if ( ! empty( $items ) ) {
99
-			foreach ( $items as $args ) {
100
-				$render = isset( $args['render'] ) ? $args['render'] : '';
101
-				if ( $render && method_exists( __CLASS__, $render ) ) {
102
-					$output .= $this->$render( $args );
103
-				}
104
-			}
105
-		}
106
-
107
-		return $output;
108
-	}
109
-
110
-	/**
111
-	 * Render and return a bootstrap alert component.
112
-	 *
113
-	 * @since 1.0.0
114
-	 *
115
-	 * @param array $args
116
-	 *
117
-	 * @return string The rendered component.
118
-	 */
119
-	public function alert( $args = array() ) {
120
-		return AUI_Component_Alert::get( $args );
121
-	}
122
-
123
-	/**
124
-	 * Render and return a bootstrap input component.
125
-	 *
126
-	 * @since 1.0.0
127
-	 *
128
-	 * @param array $args
129
-	 *
130
-	 * @return string The rendered component.
131
-	 */
132
-	public function input( $args = array() ) {
133
-		return AUI_Component_Input::input( $args );
134
-	}
135
-
136
-	/**
137
-	 * Render and return a bootstrap textarea component.
138
-	 *
139
-	 * @since 1.0.0
140
-	 *
141
-	 * @param array $args
142
-	 *
143
-	 * @return string The rendered component.
144
-	 */
145
-	public function textarea( $args = array() ) {
146
-		return AUI_Component_Input::textarea( $args );
147
-	}
148
-
149
-	/**
150
-	 * Render and return a bootstrap button component.
151
-	 *
152
-	 * @since 1.0.0
153
-	 *
154
-	 * @param array $args
155
-	 *
156
-	 * @return string The rendered component.
157
-	 */
158
-	public function button( $args = array() ) {
159
-		return AUI_Component_Button::get( $args );
160
-	}
161
-
162
-	/**
163
-	 * Render and return a bootstrap button component.
164
-	 *
165
-	 * @since 1.0.0
166
-	 *
167
-	 * @param array $args
168
-	 *
169
-	 * @return string The rendered component.
170
-	 */
171
-	public function badge( $args = array() ) {
172
-		$defaults = array(
173
-			'class' => 'badge badge-primary align-middle',
174
-		);
175
-
176
-		// maybe set type
177
-		if ( empty( $args['href'] ) ) {
178
-			$defaults['type'] = 'badge';
179
-		}
180
-
181
-		/**
182
-		 * Parse incoming $args into an array and merge it with $defaults
183
-		 */
184
-		$args = wp_parse_args( $args, $defaults );
185
-
186
-		return AUI_Component_Button::get( $args );
187
-	}
188
-
189
-	/**
190
-	 * Render and return a bootstrap dropdown component.
191
-	 *
192
-	 * @since 1.0.0
193
-	 *
194
-	 * @param array $args
195
-	 *
196
-	 * @return string The rendered component.
197
-	 */
198
-	public function dropdown( $args = array() ) {
199
-		return AUI_Component_Dropdown::get( $args );
200
-	}
201
-
202
-	/**
203
-	 * Render and return a bootstrap select component.
204
-	 *
205
-	 * @since 1.0.0
206
-	 *
207
-	 * @param array $args
208
-	 *
209
-	 * @return string The rendered component.
210
-	 */
211
-	public function select( $args = array() ) {
212
-		return AUI_Component_Input::select( $args );
213
-	}
214
-
215
-	/**
216
-	 * Render and return a bootstrap radio component.
217
-	 *
218
-	 * @since 1.0.0
219
-	 *
220
-	 * @param array $args
221
-	 *
222
-	 * @return string The rendered component.
223
-	 */
224
-	public function radio( $args = array() ) {
225
-		return AUI_Component_Input::radio( $args );
226
-	}
227
-
228
-	/**
229
-	 * Render and return a bootstrap pagination component.
230
-	 *
231
-	 * @since 1.0.0
232
-	 *
233
-	 * @param array $args
234
-	 *
235
-	 * @return string The rendered component.
236
-	 */
237
-	public function pagination( $args = array() ) {
238
-		return AUI_Component_Pagination::get( $args );
239
-	}
14
+    /**
15
+     * Holds the class instance.
16
+     *
17
+     * @since 1.0.0
18
+     * @var null
19
+     */
20
+    private static $instance = null;
21
+
22
+    /**
23
+     * Holds the current AUI version number.
24
+     *
25
+     * @var string $ver The current version number.
26
+     */
27
+    public static $ver = '0.1.61';
28
+
29
+    public static $options = null;
30
+
31
+    /**
32
+     * There can be only one.
33
+     *
34
+     * @since 1.0.0
35
+     * @return AUI|null
36
+     */
37
+    public static function instance() {
38
+        if ( self::$instance == null ) {
39
+            self::$instance = new AUI();
40
+        }
41
+
42
+        return self::$instance;
43
+    }
44
+
45
+    /**
46
+     * AUI constructor.
47
+     *
48
+     * @since 1.0.0
49
+     */
50
+    private function __construct() {
51
+        if ( function_exists( "__autoload" ) ) {
52
+            spl_autoload_register( "__autoload" );
53
+        }
54
+        spl_autoload_register( array( $this, 'autoload' ) );
55
+
56
+        // load options
57
+        self::$options = get_option('aui_options');
58
+    }
59
+
60
+    /**
61
+     * Autoload any components on the fly.
62
+     *
63
+     * @since 1.0.0
64
+     *
65
+     * @param $classname
66
+     */
67
+    private function autoload( $classname ) {
68
+        $class     = str_replace( '_', '-', strtolower( $classname ) );
69
+        $file_path = trailingslashit( dirname( __FILE__ ) ) . "components/class-" . $class . '.php';
70
+        if ( $file_path && is_readable( $file_path ) ) {
71
+            include_once( $file_path );
72
+        }
73
+    }
74
+
75
+    /**
76
+     * Get the AUI options.
77
+     *
78
+     * @param $option
79
+     *
80
+     * @return string|void
81
+     */
82
+    public function get_option( $option ){
83
+        $result = isset(self::$options[$option]) ? esc_attr(self::$options[$option]) : '';
84
+
85
+        if ( ! $result && $option) {
86
+            if( $option == 'color_primary' ){
87
+                $result = AUI_PRIMARY_COLOR;
88
+            }elseif( $option == 'color_secondary' ){
89
+                $result = AUI_SECONDARY_COLOR;
90
+            }
91
+        }
92
+        return $result;
93
+    }
94
+
95
+    public function render( $items = array() ) {
96
+        $output = '';
97
+
98
+        if ( ! empty( $items ) ) {
99
+            foreach ( $items as $args ) {
100
+                $render = isset( $args['render'] ) ? $args['render'] : '';
101
+                if ( $render && method_exists( __CLASS__, $render ) ) {
102
+                    $output .= $this->$render( $args );
103
+                }
104
+            }
105
+        }
106
+
107
+        return $output;
108
+    }
109
+
110
+    /**
111
+     * Render and return a bootstrap alert component.
112
+     *
113
+     * @since 1.0.0
114
+     *
115
+     * @param array $args
116
+     *
117
+     * @return string The rendered component.
118
+     */
119
+    public function alert( $args = array() ) {
120
+        return AUI_Component_Alert::get( $args );
121
+    }
122
+
123
+    /**
124
+     * Render and return a bootstrap input component.
125
+     *
126
+     * @since 1.0.0
127
+     *
128
+     * @param array $args
129
+     *
130
+     * @return string The rendered component.
131
+     */
132
+    public function input( $args = array() ) {
133
+        return AUI_Component_Input::input( $args );
134
+    }
135
+
136
+    /**
137
+     * Render and return a bootstrap textarea component.
138
+     *
139
+     * @since 1.0.0
140
+     *
141
+     * @param array $args
142
+     *
143
+     * @return string The rendered component.
144
+     */
145
+    public function textarea( $args = array() ) {
146
+        return AUI_Component_Input::textarea( $args );
147
+    }
148
+
149
+    /**
150
+     * Render and return a bootstrap button component.
151
+     *
152
+     * @since 1.0.0
153
+     *
154
+     * @param array $args
155
+     *
156
+     * @return string The rendered component.
157
+     */
158
+    public function button( $args = array() ) {
159
+        return AUI_Component_Button::get( $args );
160
+    }
161
+
162
+    /**
163
+     * Render and return a bootstrap button component.
164
+     *
165
+     * @since 1.0.0
166
+     *
167
+     * @param array $args
168
+     *
169
+     * @return string The rendered component.
170
+     */
171
+    public function badge( $args = array() ) {
172
+        $defaults = array(
173
+            'class' => 'badge badge-primary align-middle',
174
+        );
175
+
176
+        // maybe set type
177
+        if ( empty( $args['href'] ) ) {
178
+            $defaults['type'] = 'badge';
179
+        }
180
+
181
+        /**
182
+         * Parse incoming $args into an array and merge it with $defaults
183
+         */
184
+        $args = wp_parse_args( $args, $defaults );
185
+
186
+        return AUI_Component_Button::get( $args );
187
+    }
188
+
189
+    /**
190
+     * Render and return a bootstrap dropdown component.
191
+     *
192
+     * @since 1.0.0
193
+     *
194
+     * @param array $args
195
+     *
196
+     * @return string The rendered component.
197
+     */
198
+    public function dropdown( $args = array() ) {
199
+        return AUI_Component_Dropdown::get( $args );
200
+    }
201
+
202
+    /**
203
+     * Render and return a bootstrap select component.
204
+     *
205
+     * @since 1.0.0
206
+     *
207
+     * @param array $args
208
+     *
209
+     * @return string The rendered component.
210
+     */
211
+    public function select( $args = array() ) {
212
+        return AUI_Component_Input::select( $args );
213
+    }
214
+
215
+    /**
216
+     * Render and return a bootstrap radio component.
217
+     *
218
+     * @since 1.0.0
219
+     *
220
+     * @param array $args
221
+     *
222
+     * @return string The rendered component.
223
+     */
224
+    public function radio( $args = array() ) {
225
+        return AUI_Component_Input::radio( $args );
226
+    }
227
+
228
+    /**
229
+     * Render and return a bootstrap pagination component.
230
+     *
231
+     * @since 1.0.0
232
+     *
233
+     * @param array $args
234
+     *
235
+     * @return string The rendered component.
236
+     */
237
+    public function pagination( $args = array() ) {
238
+        return AUI_Component_Pagination::get( $args );
239
+    }
240 240
 
241 241
 }
242 242
\ No newline at end of file
Please login to merge, or discard this patch.
templates/payment-forms/cart-item.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -26,76 +26,76 @@  discard block
 block discarded – undo
26 26
 
27 27
 				<?php
28 28
 
29
-					// Fires before printing a line item column.
30
-					do_action( "getpaid_form_cart_item_before_$key", $item, $form );
29
+                    // Fires before printing a line item column.
30
+                    do_action( "getpaid_form_cart_item_before_$key", $item, $form );
31 31
 
32
-					// Item name.
33
-					if ( 'name' == $key ) {
32
+                    // Item name.
33
+                    if ( 'name' == $key ) {
34 34
 
35
-						// Display the name.
36
-						echo '<div class="mb-1">' . esc_html( $item->get_name() ) . '</div>';
35
+                        // Display the name.
36
+                        echo '<div class="mb-1">' . esc_html( $item->get_name() ) . '</div>';
37 37
 
38
-						// And an optional description.
38
+                        // And an optional description.
39 39
                         $description = $item->get_description();
40 40
 
41 41
                         if ( ! empty( $description ) ) {
42 42
                             $description = wp_kses_post( $description );
43 43
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
44
-						}
44
+                        }
45 45
 
46
-						// Price help text.
46
+                        // Price help text.
47 47
                         $description = getpaid_item_recurring_price_help_text( $item, $currency );
48 48
                         if ( $description ) {
49 49
                             echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>";
50
-						}
50
+                        }
51 51
 
52
-						if ( wpinv_current_user_can_manage_invoicing() ) {
52
+                        if ( wpinv_current_user_can_manage_invoicing() ) {
53 53
 
54
-							edit_post_link(
55
-								__( 'Edit this item.', 'invoicing' ),
56
-								'<small class="form-text text-muted">',
57
-								'</small>',
58
-								$item->get_id(),
59
-								'text-danger'
60
-							);
54
+                            edit_post_link(
55
+                                __( 'Edit this item.', 'invoicing' ),
56
+                                '<small class="form-text text-muted">',
57
+                                '</small>',
58
+                                $item->get_id(),
59
+                                'text-danger'
60
+                            );
61 61
 
62
-						}
62
+                        }
63 63
 
64
-					}
64
+                    }
65 65
 
66
-					// Item price.
67
-					if ( 'price' == $key ) {
66
+                    // Item price.
67
+                    if ( 'price' == $key ) {
68 68
 
69
-						// Set the currency position.
70
-						$position = wpinv_currency_position();
69
+                        // Set the currency position.
70
+                        $position = wpinv_currency_position();
71 71
 
72
-						if ( $position == 'left_space' ) {
73
-							$position = 'left';
74
-						}
72
+                        if ( $position == 'left_space' ) {
73
+                            $position = 'left';
74
+                        }
75 75
 
76
-						if ( $position == 'right_space' ) {
77
-							$position = 'right';
78
-						}
76
+                        if ( $position == 'right_space' ) {
77
+                            $position = 'right';
78
+                        }
79 79
 
80
-						if ( $item->user_can_set_their_price() ) {
81
-							$price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
82
-							$minimum          = (float) $item->get_minimum_price();
83
-							$validate_minimum = '';
84
-							$class            = '';
85
-							$data_minimum     = '';
80
+                        if ( $item->user_can_set_their_price() ) {
81
+                            $price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
82
+                            $minimum          = (float) $item->get_minimum_price();
83
+                            $validate_minimum = '';
84
+                            $class            = '';
85
+                            $data_minimum     = '';
86 86
 
87
-							if ( $minimum > 0 ) {
88
-								$validate_minimum = sprintf(
89
-									esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
90
-									strip_tags( wpinv_price( $minimum, $currency ) )
91
-								);
87
+                            if ( $minimum > 0 ) {
88
+                                $validate_minimum = sprintf(
89
+                                    esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
90
+                                    strip_tags( wpinv_price( $minimum, $currency ) )
91
+                                );
92 92
 
93
-								$class = 'getpaid-validate-minimum-amount';
93
+                                $class = 'getpaid-validate-minimum-amount';
94 94
 
95
-								$data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
96
-							}
95
+                                $data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
96
+                            }
97 97
 
98
-							?>
98
+                            ?>
99 99
 								<div class="input-group input-group-sm">
100 100
 									<?php if( 'left' == $position ) : ?>
101 101
 										<div class="input-group-prepend">
@@ -119,38 +119,38 @@  discard block
 block discarded – undo
119 119
 								</div>
120 120
 
121 121
 							<?php
122
-						} else {
123
-							echo wpinv_price( $item->get_price(), $currency );
124
-							?>
122
+                        } else {
123
+                            echo wpinv_price( $item->get_price(), $currency );
124
+                            ?>
125 125
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'>
126 126
 							<?php
127
-						}
128
-					}
127
+                        }
128
+                    }
129 129
 
130
-					// Item quantity.
131
-					if ( 'quantity' == $key ) {
130
+                    // Item quantity.
131
+                    if ( 'quantity' == $key ) {
132 132
 
133
-						if ( $item->allows_quantities() ) {
134
-							?>
133
+                        if ( $item->allows_quantities() ) {
134
+                            ?>
135 135
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='text' style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity() == 0 ? 1 : (float) $item->get_quantity(); ?>' min='1' required>
136 136
 							<?php
137
-						} else {
138
-							echo (float) $item->get_quantity();
139
-							echo '&nbsp;&nbsp;&nbsp;';
140
-							?>
137
+                        } else {
138
+                            echo (float) $item->get_quantity();
139
+                            echo '&nbsp;&nbsp;&nbsp;';
140
+                            ?>
141 141
 								<input type='hidden' name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' class='getpaid-item-quantity-input' value='<?php echo (float) $item->get_quantity(); ?>'>
142 142
 							<?php
143
-						}
143
+                        }
144 144
 
145
-					}
145
+                    }
146 146
 
147
-					// Item sub total.
148
-					if ( 'subtotal' == $key ) {
149
-						echo wpinv_price( $item->get_sub_total(), $currency );
150
-					}
147
+                    // Item sub total.
148
+                    if ( 'subtotal' == $key ) {
149
+                        echo wpinv_price( $item->get_sub_total(), $currency );
150
+                    }
151 151
 
152
-					do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
153
-				?>
152
+                    do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
153
+                ?>
154 154
 
155 155
 			</div>
156 156
 
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Indentation   +2546 added lines, -2546 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         'state'                => null,
61 61
         'zip'                  => null,
62 62
         'company'              => null,
63
-		'company_id'           => null,
63
+        'company_id'           => null,
64 64
         'vat_number'           => null,
65 65
         'vat_rate'             => null,
66 66
         'address'              => null,
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
         'subtotal'             => 0,
69 69
         'total_discount'       => 0,
70 70
         'total_tax'            => 0,
71
-		'total_fees'           => 0,
72
-		'total'                => 0,
71
+        'total_fees'           => 0,
72
+        'total'                => 0,
73 73
         'fees'                 => array(),
74 74
         'discounts'            => array(),
75 75
         'taxes'                => array(),
@@ -81,22 +81,22 @@  discard block
 block discarded – undo
81 81
         'transaction_id'       => '',
82 82
         'currency'             => '',
83 83
         'disable_taxes'        => false,
84
-		'subscription_id'      => null,
85
-		'remote_subscription_id' => null,
86
-		'is_viewed'            => false,
87
-		'email_cc'             => '',
88
-		'template'             => 'quantity', // hours, amount only
89
-		'created_via'          => null,
84
+        'subscription_id'      => null,
85
+        'remote_subscription_id' => null,
86
+        'is_viewed'            => false,
87
+        'email_cc'             => '',
88
+        'template'             => 'quantity', // hours, amount only
89
+        'created_via'          => null,
90 90
     );
91 91
 
92 92
     /**
93
-	 * Stores meta in cache for future reads.
94
-	 *
95
-	 * A group must be set to to enable caching.
96
-	 *
97
-	 * @var string
98
-	 */
99
-	protected $cache_group = 'getpaid_invoices';
93
+     * Stores meta in cache for future reads.
94
+     *
95
+     * A group must be set to to enable caching.
96
+     *
97
+     * @var string
98
+     */
99
+    protected $cache_group = 'getpaid_invoices';
100 100
 
101 101
     /**
102 102
      * Stores a reference to the original WP_Post object
@@ -110,111 +110,111 @@  discard block
 block discarded – undo
110 110
      *
111 111
      * @var int
112 112
      */
113
-	protected $recurring_item = null;
113
+    protected $recurring_item = null;
114 114
 
115
-	/**
115
+    /**
116 116
      * Stores an array of item totals.
117
-	 *
118
-	 * e.g $totals['discount'] = array(
119
-	 * 		'initial'   => 10,
120
-	 * 		'recurring' => 10,
121
-	 * )
117
+     *
118
+     * e.g $totals['discount'] = array(
119
+     * 		'initial'   => 10,
120
+     * 		'recurring' => 10,
121
+     * )
122 122
      *
123 123
      * @var array
124 124
      */
125
-	protected $totals = array();
125
+    protected $totals = array();
126 126
 
127
-	/**
127
+    /**
128 128
      * Tax rate.
129
-	 *
129
+     *
130 130
      * @var float
131 131
      */
132
-	protected $tax_rate = 0;
132
+    protected $tax_rate = 0;
133 133
 
134
-	/**
135
-	 * Stores the status transition information.
136
-	 *
137
-	 * @since 1.0.19
138
-	 * @var bool|array
139
-	 */
140
-	protected $status_transition = false;
134
+    /**
135
+     * Stores the status transition information.
136
+     *
137
+     * @since 1.0.19
138
+     * @var bool|array
139
+     */
140
+    protected $status_transition = false;
141 141
 
142 142
     /**
143
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
144
-	 *
145
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
146
-	 */
143
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
144
+     *
145
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
146
+     */
147 147
     public function __construct( $invoice = 0 ) {
148 148
 
149 149
         parent::__construct( $invoice );
150 150
 
151
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
152
-			$this->set_id( (int) $invoice );
153
-		} elseif ( $invoice instanceof self ) {
154
-			$this->set_id( $invoice->get_id() );
155
-		} elseif ( ! empty( $invoice->ID ) ) {
156
-			$this->set_id( $invoice->ID );
157
-		} elseif ( is_array( $invoice ) ) {
158
-			$this->set_props( $invoice );
159
-
160
-			if ( isset( $invoice['ID'] ) ) {
161
-				$this->set_id( $invoice['ID'] );
162
-			}
163
-
164
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
165
-			$this->set_id( $invoice_id );
166
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
167
-			$this->set_id( $invoice_id );
168
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
169
-			$this->set_id( $invoice_id );
170
-		} else {
171
-			$this->set_object_read( true );
172
-		}
151
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
152
+            $this->set_id( (int) $invoice );
153
+        } elseif ( $invoice instanceof self ) {
154
+            $this->set_id( $invoice->get_id() );
155
+        } elseif ( ! empty( $invoice->ID ) ) {
156
+            $this->set_id( $invoice->ID );
157
+        } elseif ( is_array( $invoice ) ) {
158
+            $this->set_props( $invoice );
159
+
160
+            if ( isset( $invoice['ID'] ) ) {
161
+                $this->set_id( $invoice['ID'] );
162
+            }
163
+
164
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
165
+            $this->set_id( $invoice_id );
166
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
167
+            $this->set_id( $invoice_id );
168
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
169
+            $this->set_id( $invoice_id );
170
+        } else {
171
+            $this->set_object_read( true );
172
+        }
173 173
 
174 174
         // Load the datastore.
175
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
175
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
176 176
 
177
-		if ( $this->get_id() > 0 ) {
177
+        if ( $this->get_id() > 0 ) {
178 178
             $this->post = get_post( $this->get_id() );
179 179
             $this->ID   = $this->get_id();
180
-			$this->data_store->read( $this );
180
+            $this->data_store->read( $this );
181 181
         }
182 182
 
183 183
     }
184 184
 
185 185
     /**
186
-	 * Given an invoice key/number, it returns its id.
187
-	 *
188
-	 *
189
-	 * @static
190
-	 * @param string $value The invoice key or number
191
-	 * @param string $field Either key, transaction_id or number.
192
-	 * @since 1.0.15
193
-	 * @return int
194
-	 */
195
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
186
+     * Given an invoice key/number, it returns its id.
187
+     *
188
+     *
189
+     * @static
190
+     * @param string $value The invoice key or number
191
+     * @param string $field Either key, transaction_id or number.
192
+     * @since 1.0.15
193
+     * @return int
194
+     */
195
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
196 196
         global $wpdb;
197 197
 
198
-		// Trim the value.
199
-		$value = trim( $value );
198
+        // Trim the value.
199
+        $value = trim( $value );
200 200
 
201
-		if ( empty( $value ) ) {
202
-			return 0;
203
-		}
201
+        if ( empty( $value ) ) {
202
+            return 0;
203
+        }
204 204
 
205 205
         // Valid fields.
206 206
         $fields = array( 'key', 'number', 'transaction_id' );
207 207
 
208
-		// Ensure a field has been passed.
209
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
210
-			return 0;
211
-		}
208
+        // Ensure a field has been passed.
209
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
210
+            return 0;
211
+        }
212 212
 
213
-		// Maybe retrieve from the cache.
214
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
-		if ( false !== $invoice_id ) {
216
-			return $invoice_id;
217
-		}
213
+        // Maybe retrieve from the cache.
214
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
+        if ( false !== $invoice_id ) {
216
+            return $invoice_id;
217
+        }
218 218
 
219 219
         // Fetch from the db.
220 220
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
223 223
         );
224 224
 
225
-		// Update the cache with our data
226
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
225
+        // Update the cache with our data
226
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
227 227
 
228
-		return $invoice_id;
228
+        return $invoice_id;
229 229
     }
230 230
 
231 231
     /**
@@ -251,83 +251,83 @@  discard block
 block discarded – undo
251 251
     */
252 252
 
253 253
     /**
254
-	 * Get parent invoice ID.
255
-	 *
256
-	 * @since 1.0.19
257
-	 * @param  string $context View or edit context.
258
-	 * @return int
259
-	 */
260
-	public function get_parent_id( $context = 'view' ) {
261
-		return (int) $this->get_prop( 'parent_id', $context );
254
+     * Get parent invoice ID.
255
+     *
256
+     * @since 1.0.19
257
+     * @param  string $context View or edit context.
258
+     * @return int
259
+     */
260
+    public function get_parent_id( $context = 'view' ) {
261
+        return (int) $this->get_prop( 'parent_id', $context );
262 262
     }
263 263
 
264 264
     /**
265
-	 * Get parent invoice.
266
-	 *
267
-	 * @since 1.0.19
268
-	 * @return WPInv_Invoice
269
-	 */
265
+     * Get parent invoice.
266
+     *
267
+     * @since 1.0.19
268
+     * @return WPInv_Invoice
269
+     */
270 270
     public function get_parent_payment() {
271 271
         return new WPInv_Invoice( $this->get_parent_id() );
272 272
     }
273 273
 
274 274
     /**
275
-	 * Alias for self::get_parent_payment().
276
-	 *
277
-	 * @since 1.0.19
278
-	 * @return WPInv_Invoice
279
-	 */
275
+     * Alias for self::get_parent_payment().
276
+     *
277
+     * @since 1.0.19
278
+     * @return WPInv_Invoice
279
+     */
280 280
     public function get_parent() {
281 281
         return $this->get_parent_payment();
282 282
     }
283 283
 
284 284
     /**
285
-	 * Get invoice status.
286
-	 *
287
-	 * @since 1.0.19
288
-	 * @param  string $context View or edit context.
289
-	 * @return string
290
-	 */
291
-	public function get_status( $context = 'view' ) {
292
-		return $this->get_prop( 'status', $context );
293
-	}
285
+     * Get invoice status.
286
+     *
287
+     * @since 1.0.19
288
+     * @param  string $context View or edit context.
289
+     * @return string
290
+     */
291
+    public function get_status( $context = 'view' ) {
292
+        return $this->get_prop( 'status', $context );
293
+    }
294 294
 	
295
-	/**
296
-	 * Retrieves an array of possible invoice statuses.
297
-	 *
298
-	 * @since 1.0.19
299
-	 * @return array
300
-	 */
301
-	public function get_all_statuses() {
302
-		return wpinv_get_invoice_statuses( true, true, $this );
303
-    }
304
-
305
-    /**
306
-	 * Get invoice status nice name.
307
-	 *
308
-	 * @since 1.0.19
309
-	 * @return string
310
-	 */
295
+    /**
296
+     * Retrieves an array of possible invoice statuses.
297
+     *
298
+     * @since 1.0.19
299
+     * @return array
300
+     */
301
+    public function get_all_statuses() {
302
+        return wpinv_get_invoice_statuses( true, true, $this );
303
+    }
304
+
305
+    /**
306
+     * Get invoice status nice name.
307
+     *
308
+     * @since 1.0.19
309
+     * @return string
310
+     */
311 311
     public function get_status_nicename() {
312
-		$statuses = $this->get_all_statuses();
312
+        $statuses = $this->get_all_statuses();
313 313
 
314 314
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
315 315
 
316 316
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
317 317
     }
318 318
 
319
-	/**
320
-	 * Retrieves the invoice status class
321
-	 *
322
-	 * @since  1.0.19
323
-	 * @return string
324
-	 */
325
-	public function get_status_class() {
326
-		$statuses = getpaid_get_invoice_status_classes();
327
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
328
-	}
319
+    /**
320
+     * Retrieves the invoice status class
321
+     *
322
+     * @since  1.0.19
323
+     * @return string
324
+     */
325
+    public function get_status_class() {
326
+        $statuses = getpaid_get_invoice_status_classes();
327
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
328
+    }
329 329
 
330
-	/**
330
+    /**
331 331
      * Retrieves the invoice status label html
332 332
      *
333 333
      * @since  1.0.0
@@ -335,263 +335,263 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function get_status_label_html() {
337 337
 
338
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
339
-		$status       = sanitize_html_class( $this->get_status() );
340
-		$class        = esc_attr( $this->get_status_class() );
338
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
339
+        $status       = sanitize_html_class( $this->get_status() );
340
+        $class        = esc_attr( $this->get_status_class() );
341 341
 
342
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
343
-	}
342
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
343
+    }
344 344
 
345 345
     /**
346
-	 * Get plugin version when the invoice was created.
347
-	 *
348
-	 * @since 1.0.19
349
-	 * @param  string $context View or edit context.
350
-	 * @return string
351
-	 */
352
-	public function get_version( $context = 'view' ) {
353
-		return $this->get_prop( 'version', $context );
354
-	}
346
+     * Get plugin version when the invoice was created.
347
+     *
348
+     * @since 1.0.19
349
+     * @param  string $context View or edit context.
350
+     * @return string
351
+     */
352
+    public function get_version( $context = 'view' ) {
353
+        return $this->get_prop( 'version', $context );
354
+    }
355 355
 
356
-	/**
357
-	 * @deprecated
358
-	 */
359
-	public function get_invoice_date( $format = true ) {
360
-		$date      = getpaid_format_date( $this->get_date_completed() );
361
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
362
-		$formatted = getpaid_format_date( $date );
356
+    /**
357
+     * @deprecated
358
+     */
359
+    public function get_invoice_date( $format = true ) {
360
+        $date      = getpaid_format_date( $this->get_date_completed() );
361
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
362
+        $formatted = getpaid_format_date( $date );
363 363
 
364
-		if ( $format ) {
365
-			return $formatted;
366
-		}
364
+        if ( $format ) {
365
+            return $formatted;
366
+        }
367 367
 
368
-		return empty( $formatted ) ? '' : $date;
368
+        return empty( $formatted ) ? '' : $date;
369 369
 
370 370
     }
371 371
 
372 372
     /**
373
-	 * Get date when the invoice was created.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_date_created( $context = 'view' ) {
380
-		return $this->get_prop( 'date_created', $context );
381
-	}
373
+     * Get date when the invoice was created.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_date_created( $context = 'view' ) {
380
+        return $this->get_prop( 'date_created', $context );
381
+    }
382 382
 	
383
-	/**
384
-	 * Alias for self::get_date_created().
385
-	 *
386
-	 * @since 1.0.19
387
-	 * @param  string $context View or edit context.
388
-	 * @return string
389
-	 */
390
-	public function get_created_date( $context = 'view' ) {
391
-		return $this->get_date_created( $context );
392
-    }
393
-
394
-    /**
395
-	 * Get GMT date when the invoice was created.
396
-	 *
397
-	 * @since 1.0.19
398
-	 * @param  string $context View or edit context.
399
-	 * @return string
400
-	 */
401
-	public function get_date_created_gmt( $context = 'view' ) {
383
+    /**
384
+     * Alias for self::get_date_created().
385
+     *
386
+     * @since 1.0.19
387
+     * @param  string $context View or edit context.
388
+     * @return string
389
+     */
390
+    public function get_created_date( $context = 'view' ) {
391
+        return $this->get_date_created( $context );
392
+    }
393
+
394
+    /**
395
+     * Get GMT date when the invoice was created.
396
+     *
397
+     * @since 1.0.19
398
+     * @param  string $context View or edit context.
399
+     * @return string
400
+     */
401
+    public function get_date_created_gmt( $context = 'view' ) {
402 402
         $date = $this->get_date_created( $context );
403 403
 
404 404
         if ( $date ) {
405 405
             $date = get_gmt_from_date( $date );
406 406
         }
407
-		return $date;
407
+        return $date;
408 408
     }
409 409
 
410 410
     /**
411
-	 * Get date when the invoice was last modified.
412
-	 *
413
-	 * @since 1.0.19
414
-	 * @param  string $context View or edit context.
415
-	 * @return string
416
-	 */
417
-	public function get_date_modified( $context = 'view' ) {
418
-		return $this->get_prop( 'date_modified', $context );
419
-	}
411
+     * Get date when the invoice was last modified.
412
+     *
413
+     * @since 1.0.19
414
+     * @param  string $context View or edit context.
415
+     * @return string
416
+     */
417
+    public function get_date_modified( $context = 'view' ) {
418
+        return $this->get_prop( 'date_modified', $context );
419
+    }
420 420
 
421
-	/**
422
-	 * Alias for self::get_date_modified().
423
-	 *
424
-	 * @since 1.0.19
425
-	 * @param  string $context View or edit context.
426
-	 * @return string
427
-	 */
428
-	public function get_modified_date( $context = 'view' ) {
429
-		return $this->get_date_modified( $context );
421
+    /**
422
+     * Alias for self::get_date_modified().
423
+     *
424
+     * @since 1.0.19
425
+     * @param  string $context View or edit context.
426
+     * @return string
427
+     */
428
+    public function get_modified_date( $context = 'view' ) {
429
+        return $this->get_date_modified( $context );
430 430
     }
431 431
 
432 432
     /**
433
-	 * Get GMT date when the invoice was last modified.
434
-	 *
435
-	 * @since 1.0.19
436
-	 * @param  string $context View or edit context.
437
-	 * @return string
438
-	 */
439
-	public function get_date_modified_gmt( $context = 'view' ) {
433
+     * Get GMT date when the invoice was last modified.
434
+     *
435
+     * @since 1.0.19
436
+     * @param  string $context View or edit context.
437
+     * @return string
438
+     */
439
+    public function get_date_modified_gmt( $context = 'view' ) {
440 440
         $date = $this->get_date_modified( $context );
441 441
 
442 442
         if ( $date ) {
443 443
             $date = get_gmt_from_date( $date );
444 444
         }
445
-		return $date;
445
+        return $date;
446 446
     }
447 447
 
448 448
     /**
449
-	 * Get the invoice due date.
450
-	 *
451
-	 * @since 1.0.19
452
-	 * @param  string $context View or edit context.
453
-	 * @return string
454
-	 */
455
-	public function get_due_date( $context = 'view' ) {
456
-		return $this->get_prop( 'due_date', $context );
449
+     * Get the invoice due date.
450
+     *
451
+     * @since 1.0.19
452
+     * @param  string $context View or edit context.
453
+     * @return string
454
+     */
455
+    public function get_due_date( $context = 'view' ) {
456
+        return $this->get_prop( 'due_date', $context );
457 457
     }
458 458
 
459 459
     /**
460
-	 * Alias for self::get_due_date().
461
-	 *
462
-	 * @since 1.0.19
463
-	 * @param  string $context View or edit context.
464
-	 * @return string
465
-	 */
466
-	public function get_date_due( $context = 'view' ) {
467
-		return $this->get_due_date( $context );
460
+     * Alias for self::get_due_date().
461
+     *
462
+     * @since 1.0.19
463
+     * @param  string $context View or edit context.
464
+     * @return string
465
+     */
466
+    public function get_date_due( $context = 'view' ) {
467
+        return $this->get_due_date( $context );
468 468
     }
469 469
 
470 470
     /**
471
-	 * Get the invoice GMT due date.
472
-	 *
473
-	 * @since 1.0.19
474
-	 * @param  string $context View or edit context.
475
-	 * @return string
476
-	 */
477
-	public function get_due_date_gmt( $context = 'view' ) {
471
+     * Get the invoice GMT due date.
472
+     *
473
+     * @since 1.0.19
474
+     * @param  string $context View or edit context.
475
+     * @return string
476
+     */
477
+    public function get_due_date_gmt( $context = 'view' ) {
478 478
         $date = $this->get_due_date( $context );
479 479
 
480 480
         if ( $date ) {
481 481
             $date = get_gmt_from_date( $date );
482 482
         }
483
-		return $date;
483
+        return $date;
484 484
     }
485 485
 
486 486
     /**
487
-	 * Alias for self::get_due_date_gmt().
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_gmt_date_due( $context = 'view' ) {
494
-		return $this->get_due_date_gmt( $context );
487
+     * Alias for self::get_due_date_gmt().
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_gmt_date_due( $context = 'view' ) {
494
+        return $this->get_due_date_gmt( $context );
495 495
     }
496 496
 
497 497
     /**
498
-	 * Get date when the invoice was completed.
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_completed_date( $context = 'view' ) {
505
-		return $this->get_prop( 'completed_date', $context );
498
+     * Get date when the invoice was completed.
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_completed_date( $context = 'view' ) {
505
+        return $this->get_prop( 'completed_date', $context );
506 506
     }
507 507
 
508 508
     /**
509
-	 * Alias for self::get_completed_date().
510
-	 *
511
-	 * @since 1.0.19
512
-	 * @param  string $context View or edit context.
513
-	 * @return string
514
-	 */
515
-	public function get_date_completed( $context = 'view' ) {
516
-		return $this->get_completed_date( $context );
509
+     * Alias for self::get_completed_date().
510
+     *
511
+     * @since 1.0.19
512
+     * @param  string $context View or edit context.
513
+     * @return string
514
+     */
515
+    public function get_date_completed( $context = 'view' ) {
516
+        return $this->get_completed_date( $context );
517 517
     }
518 518
 
519 519
     /**
520
-	 * Get GMT date when the invoice was was completed.
521
-	 *
522
-	 * @since 1.0.19
523
-	 * @param  string $context View or edit context.
524
-	 * @return string
525
-	 */
526
-	public function get_completed_date_gmt( $context = 'view' ) {
520
+     * Get GMT date when the invoice was was completed.
521
+     *
522
+     * @since 1.0.19
523
+     * @param  string $context View or edit context.
524
+     * @return string
525
+     */
526
+    public function get_completed_date_gmt( $context = 'view' ) {
527 527
         $date = $this->get_completed_date( $context );
528 528
 
529 529
         if ( $date ) {
530 530
             $date = get_gmt_from_date( $date );
531 531
         }
532
-		return $date;
532
+        return $date;
533 533
     }
534 534
 
535 535
     /**
536
-	 * Alias for self::get_completed_date_gmt().
537
-	 *
538
-	 * @since 1.0.19
539
-	 * @param  string $context View or edit context.
540
-	 * @return string
541
-	 */
542
-	public function get_gmt_completed_date( $context = 'view' ) {
543
-		return $this->get_completed_date_gmt( $context );
536
+     * Alias for self::get_completed_date_gmt().
537
+     *
538
+     * @since 1.0.19
539
+     * @param  string $context View or edit context.
540
+     * @return string
541
+     */
542
+    public function get_gmt_completed_date( $context = 'view' ) {
543
+        return $this->get_completed_date_gmt( $context );
544 544
     }
545 545
 
546 546
     /**
547
-	 * Get the invoice number.
548
-	 *
549
-	 * @since 1.0.19
550
-	 * @param  string $context View or edit context.
551
-	 * @return string
552
-	 */
553
-	public function get_number( $context = 'view' ) {
554
-		$number = $this->get_prop( 'number', $context );
547
+     * Get the invoice number.
548
+     *
549
+     * @since 1.0.19
550
+     * @param  string $context View or edit context.
551
+     * @return string
552
+     */
553
+    public function get_number( $context = 'view' ) {
554
+        $number = $this->get_prop( 'number', $context );
555 555
 
556
-		if ( empty( $number ) ) {
557
-			$number = $this->generate_number();
558
-			$this->set_number( $this->generate_number() );
559
-		}
556
+        if ( empty( $number ) ) {
557
+            $number = $this->generate_number();
558
+            $this->set_number( $this->generate_number() );
559
+        }
560 560
 
561
-		return $number;
561
+        return $number;
562 562
     }
563 563
 
564
-	/**
565
-	 * Set the invoice number.
566
-	 *
567
-	 * @since 1.0.19
568
-	 */
569
-	public function maybe_set_number() {
564
+    /**
565
+     * Set the invoice number.
566
+     *
567
+     * @since 1.0.19
568
+     */
569
+    public function maybe_set_number() {
570 570
         $number = $this->get_number();
571 571
 
572 572
         if ( empty( $number ) || $this->get_id() == $number ) {
573
-			$this->set_number( $this->generate_number() );
573
+            $this->set_number( $this->generate_number() );
574 574
         }
575 575
 
576
-	}
576
+    }
577 577
 
578 578
     /**
579
-	 * Get the invoice key.
580
-	 *
581
-	 * @since 1.0.19
582
-	 * @param  string $context View or edit context.
583
-	 * @return string
584
-	 */
585
-	public function get_key( $context = 'view' ) {
579
+     * Get the invoice key.
580
+     *
581
+     * @since 1.0.19
582
+     * @param  string $context View or edit context.
583
+     * @return string
584
+     */
585
+    public function get_key( $context = 'view' ) {
586 586
         return $this->get_prop( 'key', $context );
587
-	}
588
-
589
-	/**
590
-	 * Set the invoice key.
591
-	 *
592
-	 * @since 1.0.19
593
-	 */
594
-	public function maybe_set_key() {
587
+    }
588
+
589
+    /**
590
+     * Set the invoice key.
591
+     *
592
+     * @since 1.0.19
593
+     */
594
+    public function maybe_set_key() {
595 595
         $key = $this->get_key();
596 596
 
597 597
         if ( empty( $key ) ) {
@@ -602,140 +602,140 @@  discard block
 block discarded – undo
602 602
     }
603 603
 
604 604
     /**
605
-	 * Get the invoice type.
606
-	 *
607
-	 * @since 1.0.19
608
-	 * @param  string $context View or edit context.
609
-	 * @return string
610
-	 */
611
-	public function get_type( $context = 'view' ) {
605
+     * Get the invoice type.
606
+     *
607
+     * @since 1.0.19
608
+     * @param  string $context View or edit context.
609
+     * @return string
610
+     */
611
+    public function get_type( $context = 'view' ) {
612 612
         return $this->get_prop( 'type', $context );
613
-	}
614
-
615
-	/**
616
-	 * Returns the post type name.
617
-	 *
618
-	 * @since 1.0.19
619
-	 * @return string
620
-	 */
621
-	public function get_invoice_quote_type() {
613
+    }
614
+
615
+    /**
616
+     * Returns the post type name.
617
+     *
618
+     * @since 1.0.19
619
+     * @return string
620
+     */
621
+    public function get_invoice_quote_type() {
622 622
         return getpaid_get_post_type_label( $this->get_post_type(), false );
623 623
     }
624 624
 
625 625
     /**
626
-	 * Get the invoice post type label.
627
-	 *
628
-	 * @since 1.0.19
629
-	 * @param  string $context View or edit context.
630
-	 * @return string
631
-	 */
632
-	public function get_label( $context = 'view' ) {
626
+     * Get the invoice post type label.
627
+     *
628
+     * @since 1.0.19
629
+     * @param  string $context View or edit context.
630
+     * @return string
631
+     */
632
+    public function get_label( $context = 'view' ) {
633 633
         return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
634
-	}
635
-
636
-	/**
637
-	 * Get the invoice post type.
638
-	 *
639
-	 * @since 1.0.19
640
-	 * @param  string $context View or edit context.
641
-	 * @return string
642
-	 */
643
-	public function get_post_type( $context = 'view' ) {
634
+    }
635
+
636
+    /**
637
+     * Get the invoice post type.
638
+     *
639
+     * @since 1.0.19
640
+     * @param  string $context View or edit context.
641
+     * @return string
642
+     */
643
+    public function get_post_type( $context = 'view' ) {
644 644
         return $this->get_prop( 'post_type', $context );
645 645
     }
646 646
 
647 647
     /**
648
-	 * Get the invoice mode.
649
-	 *
650
-	 * @since 1.0.19
651
-	 * @param  string $context View or edit context.
652
-	 * @return string
653
-	 */
654
-	public function get_mode( $context = 'view' ) {
648
+     * Get the invoice mode.
649
+     *
650
+     * @since 1.0.19
651
+     * @param  string $context View or edit context.
652
+     * @return string
653
+     */
654
+    public function get_mode( $context = 'view' ) {
655 655
         return $this->get_prop( 'mode', $context );
656 656
     }
657 657
 
658 658
     /**
659
-	 * Get the invoice path.
660
-	 *
661
-	 * @since 1.0.19
662
-	 * @param  string $context View or edit context.
663
-	 * @return string
664
-	 */
665
-	public function get_path( $context = 'view' ) {
659
+     * Get the invoice path.
660
+     *
661
+     * @since 1.0.19
662
+     * @param  string $context View or edit context.
663
+     * @return string
664
+     */
665
+    public function get_path( $context = 'view' ) {
666 666
         $path   = $this->get_prop( 'path', $context );
667
-		$prefix = $this->get_type();
667
+        $prefix = $this->get_type();
668 668
 
669
-		if ( 0 !== strpos( $path, $prefix ) ) {
670
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
671
-			$this->set_path( $path );
672
-		}
669
+        if ( 0 !== strpos( $path, $prefix ) ) {
670
+            $path = sanitize_title(  $prefix . '-' . $this->get_id()  );
671
+            $this->set_path( $path );
672
+        }
673 673
 
674
-		return $path;
674
+        return $path;
675 675
     }
676 676
 
677 677
     /**
678
-	 * Get the invoice name/title.
679
-	 *
680
-	 * @since 1.0.19
681
-	 * @param  string $context View or edit context.
682
-	 * @return string
683
-	 */
684
-	public function get_name( $context = 'view' ) {
678
+     * Get the invoice name/title.
679
+     *
680
+     * @since 1.0.19
681
+     * @param  string $context View or edit context.
682
+     * @return string
683
+     */
684
+    public function get_name( $context = 'view' ) {
685 685
         return $this->get_prop( 'title', $context );
686 686
     }
687 687
 
688 688
     /**
689
-	 * Alias of self::get_name().
690
-	 *
691
-	 * @since 1.0.19
692
-	 * @param  string $context View or edit context.
693
-	 * @return string
694
-	 */
695
-	public function get_title( $context = 'view' ) {
696
-		return $this->get_name( $context );
689
+     * Alias of self::get_name().
690
+     *
691
+     * @since 1.0.19
692
+     * @param  string $context View or edit context.
693
+     * @return string
694
+     */
695
+    public function get_title( $context = 'view' ) {
696
+        return $this->get_name( $context );
697 697
     }
698 698
 
699 699
     /**
700
-	 * Get the invoice description.
701
-	 *
702
-	 * @since 1.0.19
703
-	 * @param  string $context View or edit context.
704
-	 * @return string
705
-	 */
706
-	public function get_description( $context = 'view' ) {
707
-		return $this->get_prop( 'description', $context );
700
+     * Get the invoice description.
701
+     *
702
+     * @since 1.0.19
703
+     * @param  string $context View or edit context.
704
+     * @return string
705
+     */
706
+    public function get_description( $context = 'view' ) {
707
+        return $this->get_prop( 'description', $context );
708 708
     }
709 709
 
710 710
     /**
711
-	 * Alias of self::get_description().
712
-	 *
713
-	 * @since 1.0.19
714
-	 * @param  string $context View or edit context.
715
-	 * @return string
716
-	 */
717
-	public function get_excerpt( $context = 'view' ) {
718
-		return $this->get_description( $context );
711
+     * Alias of self::get_description().
712
+     *
713
+     * @since 1.0.19
714
+     * @param  string $context View or edit context.
715
+     * @return string
716
+     */
717
+    public function get_excerpt( $context = 'view' ) {
718
+        return $this->get_description( $context );
719 719
     }
720 720
 
721 721
     /**
722
-	 * Alias of self::get_description().
723
-	 *
724
-	 * @since 1.0.19
725
-	 * @param  string $context View or edit context.
726
-	 * @return string
727
-	 */
728
-	public function get_summary( $context = 'view' ) {
729
-		return $this->get_description( $context );
722
+     * Alias of self::get_description().
723
+     *
724
+     * @since 1.0.19
725
+     * @param  string $context View or edit context.
726
+     * @return string
727
+     */
728
+    public function get_summary( $context = 'view' ) {
729
+        return $this->get_description( $context );
730 730
     }
731 731
 
732 732
     /**
733
-	 * Returns the user info.
734
-	 *
735
-	 * @since 1.0.19
733
+     * Returns the user info.
734
+     *
735
+     * @since 1.0.19
736 736
      * @param  string $context View or edit context.
737
-	 * @return array
738
-	 */
737
+     * @return array
738
+     */
739 739
     public function get_user_info( $context = 'view' ) {
740 740
 
741 741
         $user_info = array(
@@ -750,630 +750,630 @@  discard block
 block discarded – undo
750 750
             'state'      => $this->get_state( $context ),
751 751
             'zip'        => $this->get_zip( $context ),
752 752
             'company'    => $this->get_company( $context ),
753
-			'company_id' => $this->get_company_id( $context ),
753
+            'company_id' => $this->get_company_id( $context ),
754 754
             'vat_number' => $this->get_vat_number( $context ),
755 755
             'discount'   => $this->get_discount_code( $context ),
756
-		);
756
+        );
757 757
 
758
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
758
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
759 759
 
760 760
     }
761 761
 
762 762
     /**
763
-	 * Get the customer id.
764
-	 *
765
-	 * @since 1.0.19
766
-	 * @param  string $context View or edit context.
767
-	 * @return int
768
-	 */
769
-	public function get_author( $context = 'view' ) {
770
-		return (int) $this->get_prop( 'author', $context );
763
+     * Get the customer id.
764
+     *
765
+     * @since 1.0.19
766
+     * @param  string $context View or edit context.
767
+     * @return int
768
+     */
769
+    public function get_author( $context = 'view' ) {
770
+        return (int) $this->get_prop( 'author', $context );
771 771
     }
772 772
 
773 773
     /**
774
-	 * Alias of self::get_author().
775
-	 *
776
-	 * @since 1.0.19
777
-	 * @param  string $context View or edit context.
778
-	 * @return int
779
-	 */
780
-	public function get_user_id( $context = 'view' ) {
781
-		return $this->get_author( $context );
774
+     * Alias of self::get_author().
775
+     *
776
+     * @since 1.0.19
777
+     * @param  string $context View or edit context.
778
+     * @return int
779
+     */
780
+    public function get_user_id( $context = 'view' ) {
781
+        return $this->get_author( $context );
782 782
     }
783 783
 
784
-     /**
785
-	 * Alias of self::get_author().
786
-	 *
787
-	 * @since 1.0.19
788
-	 * @param  string $context View or edit context.
789
-	 * @return int
790
-	 */
791
-	public function get_customer_id( $context = 'view' ) {
792
-		return $this->get_author( $context );
784
+        /**
785
+         * Alias of self::get_author().
786
+         *
787
+         * @since 1.0.19
788
+         * @param  string $context View or edit context.
789
+         * @return int
790
+         */
791
+    public function get_customer_id( $context = 'view' ) {
792
+        return $this->get_author( $context );
793 793
     }
794 794
 
795 795
     /**
796
-	 * Get the customer's ip.
797
-	 *
798
-	 * @since 1.0.19
799
-	 * @param  string $context View or edit context.
800
-	 * @return string
801
-	 */
802
-	public function get_ip( $context = 'view' ) {
803
-		return $this->get_prop( 'user_ip', $context );
796
+     * Get the customer's ip.
797
+     *
798
+     * @since 1.0.19
799
+     * @param  string $context View or edit context.
800
+     * @return string
801
+     */
802
+    public function get_ip( $context = 'view' ) {
803
+        return $this->get_prop( 'user_ip', $context );
804 804
     }
805 805
 
806 806
     /**
807
-	 * Alias of self::get_ip().
808
-	 *
809
-	 * @since 1.0.19
810
-	 * @param  string $context View or edit context.
811
-	 * @return string
812
-	 */
813
-	public function get_user_ip( $context = 'view' ) {
814
-		return $this->get_ip( $context );
807
+     * Alias of self::get_ip().
808
+     *
809
+     * @since 1.0.19
810
+     * @param  string $context View or edit context.
811
+     * @return string
812
+     */
813
+    public function get_user_ip( $context = 'view' ) {
814
+        return $this->get_ip( $context );
815 815
     }
816 816
 
817
-     /**
818
-	 * Alias of self::get_ip().
819
-	 *
820
-	 * @since 1.0.19
821
-	 * @param  string $context View or edit context.
822
-	 * @return string
823
-	 */
824
-	public function get_customer_ip( $context = 'view' ) {
825
-		return $this->get_ip( $context );
817
+        /**
818
+         * Alias of self::get_ip().
819
+         *
820
+         * @since 1.0.19
821
+         * @param  string $context View or edit context.
822
+         * @return string
823
+         */
824
+    public function get_customer_ip( $context = 'view' ) {
825
+        return $this->get_ip( $context );
826 826
     }
827 827
 
828 828
     /**
829
-	 * Get the customer's first name.
830
-	 *
831
-	 * @since 1.0.19
832
-	 * @param  string $context View or edit context.
833
-	 * @return string
834
-	 */
835
-	public function get_first_name( $context = 'view' ) {
836
-		return $this->get_prop( 'first_name', $context );
829
+     * Get the customer's first name.
830
+     *
831
+     * @since 1.0.19
832
+     * @param  string $context View or edit context.
833
+     * @return string
834
+     */
835
+    public function get_first_name( $context = 'view' ) {
836
+        return $this->get_prop( 'first_name', $context );
837 837
     }
838 838
 
839 839
     /**
840
-	 * Alias of self::get_first_name().
841
-	 *
842
-	 * @since 1.0.19
843
-	 * @param  string $context View or edit context.
844
-	 * @return string
845
-	 */
846
-	public function get_user_first_name( $context = 'view' ) {
847
-		return $this->get_first_name( $context );
840
+     * Alias of self::get_first_name().
841
+     *
842
+     * @since 1.0.19
843
+     * @param  string $context View or edit context.
844
+     * @return string
845
+     */
846
+    public function get_user_first_name( $context = 'view' ) {
847
+        return $this->get_first_name( $context );
848 848
     }
849 849
 
850
-     /**
851
-	 * Alias of self::get_first_name().
852
-	 *
853
-	 * @since 1.0.19
854
-	 * @param  string $context View or edit context.
855
-	 * @return string
856
-	 */
857
-	public function get_customer_first_name( $context = 'view' ) {
858
-		return $this->get_first_name( $context );
850
+        /**
851
+         * Alias of self::get_first_name().
852
+         *
853
+         * @since 1.0.19
854
+         * @param  string $context View or edit context.
855
+         * @return string
856
+         */
857
+    public function get_customer_first_name( $context = 'view' ) {
858
+        return $this->get_first_name( $context );
859 859
     }
860 860
 
861 861
     /**
862
-	 * Get the customer's last name.
863
-	 *
864
-	 * @since 1.0.19
865
-	 * @param  string $context View or edit context.
866
-	 * @return string
867
-	 */
868
-	public function get_last_name( $context = 'view' ) {
869
-		return $this->get_prop( 'last_name', $context );
862
+     * Get the customer's last name.
863
+     *
864
+     * @since 1.0.19
865
+     * @param  string $context View or edit context.
866
+     * @return string
867
+     */
868
+    public function get_last_name( $context = 'view' ) {
869
+        return $this->get_prop( 'last_name', $context );
870 870
     }
871 871
 
872 872
     /**
873
-	 * Alias of self::get_last_name().
874
-	 *
875
-	 * @since 1.0.19
876
-	 * @param  string $context View or edit context.
877
-	 * @return string
878
-	 */
879
-	public function get_user_last_name( $context = 'view' ) {
880
-		return $this->get_last_name( $context );
873
+     * Alias of self::get_last_name().
874
+     *
875
+     * @since 1.0.19
876
+     * @param  string $context View or edit context.
877
+     * @return string
878
+     */
879
+    public function get_user_last_name( $context = 'view' ) {
880
+        return $this->get_last_name( $context );
881 881
     }
882 882
 
883 883
     /**
884
-	 * Alias of self::get_last_name().
885
-	 *
886
-	 * @since 1.0.19
887
-	 * @param  string $context View or edit context.
888
-	 * @return string
889
-	 */
890
-	public function get_customer_last_name( $context = 'view' ) {
891
-		return $this->get_last_name( $context );
884
+     * Alias of self::get_last_name().
885
+     *
886
+     * @since 1.0.19
887
+     * @param  string $context View or edit context.
888
+     * @return string
889
+     */
890
+    public function get_customer_last_name( $context = 'view' ) {
891
+        return $this->get_last_name( $context );
892 892
     }
893 893
 
894 894
     /**
895
-	 * Get the customer's full name.
896
-	 *
897
-	 * @since 1.0.19
898
-	 * @param  string $context View or edit context.
899
-	 * @return string
900
-	 */
901
-	public function get_full_name( $context = 'view' ) {
902
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
895
+     * Get the customer's full name.
896
+     *
897
+     * @since 1.0.19
898
+     * @param  string $context View or edit context.
899
+     * @return string
900
+     */
901
+    public function get_full_name( $context = 'view' ) {
902
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
903 903
     }
904 904
 
905 905
     /**
906
-	 * Alias of self::get_full_name().
907
-	 *
908
-	 * @since 1.0.19
909
-	 * @param  string $context View or edit context.
910
-	 * @return string
911
-	 */
912
-	public function get_user_full_name( $context = 'view' ) {
913
-		return $this->get_full_name( $context );
906
+     * Alias of self::get_full_name().
907
+     *
908
+     * @since 1.0.19
909
+     * @param  string $context View or edit context.
910
+     * @return string
911
+     */
912
+    public function get_user_full_name( $context = 'view' ) {
913
+        return $this->get_full_name( $context );
914 914
     }
915 915
 
916 916
     /**
917
-	 * Alias of self::get_full_name().
918
-	 *
919
-	 * @since 1.0.19
920
-	 * @param  string $context View or edit context.
921
-	 * @return string
922
-	 */
923
-	public function get_customer_full_name( $context = 'view' ) {
924
-		return $this->get_full_name( $context );
917
+     * Alias of self::get_full_name().
918
+     *
919
+     * @since 1.0.19
920
+     * @param  string $context View or edit context.
921
+     * @return string
922
+     */
923
+    public function get_customer_full_name( $context = 'view' ) {
924
+        return $this->get_full_name( $context );
925 925
     }
926 926
 
927 927
     /**
928
-	 * Get the customer's phone number.
929
-	 *
930
-	 * @since 1.0.19
931
-	 * @param  string $context View or edit context.
932
-	 * @return string
933
-	 */
934
-	public function get_phone( $context = 'view' ) {
935
-		return $this->get_prop( 'phone', $context );
928
+     * Get the customer's phone number.
929
+     *
930
+     * @since 1.0.19
931
+     * @param  string $context View or edit context.
932
+     * @return string
933
+     */
934
+    public function get_phone( $context = 'view' ) {
935
+        return $this->get_prop( 'phone', $context );
936 936
     }
937 937
 
938 938
     /**
939
-	 * Alias of self::get_phone().
940
-	 *
941
-	 * @since 1.0.19
942
-	 * @param  string $context View or edit context.
943
-	 * @return string
944
-	 */
945
-	public function get_phone_number( $context = 'view' ) {
946
-		return $this->get_phone( $context );
939
+     * Alias of self::get_phone().
940
+     *
941
+     * @since 1.0.19
942
+     * @param  string $context View or edit context.
943
+     * @return string
944
+     */
945
+    public function get_phone_number( $context = 'view' ) {
946
+        return $this->get_phone( $context );
947 947
     }
948 948
 
949 949
     /**
950
-	 * Alias of self::get_phone().
951
-	 *
952
-	 * @since 1.0.19
953
-	 * @param  string $context View or edit context.
954
-	 * @return string
955
-	 */
956
-	public function get_user_phone( $context = 'view' ) {
957
-		return $this->get_phone( $context );
958
-    }
959
-
950
+     * Alias of self::get_phone().
951
+     *
952
+     * @since 1.0.19
953
+     * @param  string $context View or edit context.
954
+     * @return string
955
+     */
956
+    public function get_user_phone( $context = 'view' ) {
957
+        return $this->get_phone( $context );
958
+    }
959
+
960
+    /**
961
+     * Alias of self::get_phone().
962
+     *
963
+     * @since 1.0.19
964
+     * @param  string $context View or edit context.
965
+     * @return string
966
+     */
967
+    public function get_customer_phone( $context = 'view' ) {
968
+        return $this->get_phone( $context );
969
+    }
970
+
971
+    /**
972
+     * Get the customer's email address.
973
+     *
974
+     * @since 1.0.19
975
+     * @param  string $context View or edit context.
976
+     * @return string
977
+     */
978
+    public function get_email( $context = 'view' ) {
979
+        return $this->get_prop( 'email', $context );
980
+    }
981
+
982
+    /**
983
+     * Alias of self::get_email().
984
+     *
985
+     * @since 1.0.19
986
+     * @param  string $context View or edit context.
987
+     * @return string
988
+     */
989
+    public function get_email_address( $context = 'view' ) {
990
+        return $this->get_email( $context );
991
+    }
992
+
993
+    /**
994
+     * Alias of self::get_email().
995
+     *
996
+     * @since 1.0.19
997
+     * @param  string $context View or edit context.
998
+     * @return string
999
+     */
1000
+    public function get_user_email( $context = 'view' ) {
1001
+        return $this->get_email( $context );
1002
+    }
1003
+
960 1004
     /**
961
-	 * Alias of self::get_phone().
962
-	 *
963
-	 * @since 1.0.19
964
-	 * @param  string $context View or edit context.
965
-	 * @return string
966
-	 */
967
-	public function get_customer_phone( $context = 'view' ) {
968
-		return $this->get_phone( $context );
1005
+     * Alias of self::get_email().
1006
+     *
1007
+     * @since 1.0.19
1008
+     * @param  string $context View or edit context.
1009
+     * @return string
1010
+     */
1011
+    public function get_customer_email( $context = 'view' ) {
1012
+        return $this->get_email( $context );
969 1013
     }
970 1014
 
971 1015
     /**
972
-	 * Get the customer's email address.
973
-	 *
974
-	 * @since 1.0.19
975
-	 * @param  string $context View or edit context.
976
-	 * @return string
977
-	 */
978
-	public function get_email( $context = 'view' ) {
979
-		return $this->get_prop( 'email', $context );
1016
+     * Get the customer's country.
1017
+     *
1018
+     * @since 1.0.19
1019
+     * @param  string $context View or edit context.
1020
+     * @return string
1021
+     */
1022
+    public function get_country( $context = 'view' ) {
1023
+        $country = $this->get_prop( 'country', $context );
1024
+        return empty( $country ) ? wpinv_get_default_country() : $country;
980 1025
     }
981 1026
 
982 1027
     /**
983
-	 * Alias of self::get_email().
984
-	 *
985
-	 * @since 1.0.19
986
-	 * @param  string $context View or edit context.
987
-	 * @return string
988
-	 */
989
-	public function get_email_address( $context = 'view' ) {
990
-		return $this->get_email( $context );
1028
+     * Alias of self::get_country().
1029
+     *
1030
+     * @since 1.0.19
1031
+     * @param  string $context View or edit context.
1032
+     * @return string
1033
+     */
1034
+    public function get_user_country( $context = 'view' ) {
1035
+        return $this->get_country( $context );
991 1036
     }
992 1037
 
993 1038
     /**
994
-	 * Alias of self::get_email().
995
-	 *
996
-	 * @since 1.0.19
997
-	 * @param  string $context View or edit context.
998
-	 * @return string
999
-	 */
1000
-	public function get_user_email( $context = 'view' ) {
1001
-		return $this->get_email( $context );
1039
+     * Alias of self::get_country().
1040
+     *
1041
+     * @since 1.0.19
1042
+     * @param  string $context View or edit context.
1043
+     * @return string
1044
+     */
1045
+    public function get_customer_country( $context = 'view' ) {
1046
+        return $this->get_country( $context );
1002 1047
     }
1003 1048
 
1004 1049
     /**
1005
-	 * Alias of self::get_email().
1006
-	 *
1007
-	 * @since 1.0.19
1008
-	 * @param  string $context View or edit context.
1009
-	 * @return string
1010
-	 */
1011
-	public function get_customer_email( $context = 'view' ) {
1012
-		return $this->get_email( $context );
1050
+     * Get the customer's state.
1051
+     *
1052
+     * @since 1.0.19
1053
+     * @param  string $context View or edit context.
1054
+     * @return string
1055
+     */
1056
+    public function get_state( $context = 'view' ) {
1057
+        $state = $this->get_prop( 'state', $context );
1058
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1013 1059
     }
1014 1060
 
1015 1061
     /**
1016
-	 * Get the customer's country.
1017
-	 *
1018
-	 * @since 1.0.19
1019
-	 * @param  string $context View or edit context.
1020
-	 * @return string
1021
-	 */
1022
-	public function get_country( $context = 'view' ) {
1023
-		$country = $this->get_prop( 'country', $context );
1024
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1062
+     * Alias of self::get_state().
1063
+     *
1064
+     * @since 1.0.19
1065
+     * @param  string $context View or edit context.
1066
+     * @return string
1067
+     */
1068
+    public function get_user_state( $context = 'view' ) {
1069
+        return $this->get_state( $context );
1025 1070
     }
1026 1071
 
1027 1072
     /**
1028
-	 * Alias of self::get_country().
1029
-	 *
1030
-	 * @since 1.0.19
1031
-	 * @param  string $context View or edit context.
1032
-	 * @return string
1033
-	 */
1034
-	public function get_user_country( $context = 'view' ) {
1035
-		return $this->get_country( $context );
1073
+     * Alias of self::get_state().
1074
+     *
1075
+     * @since 1.0.19
1076
+     * @param  string $context View or edit context.
1077
+     * @return string
1078
+     */
1079
+    public function get_customer_state( $context = 'view' ) {
1080
+        return $this->get_state( $context );
1036 1081
     }
1037 1082
 
1038 1083
     /**
1039
-	 * Alias of self::get_country().
1040
-	 *
1041
-	 * @since 1.0.19
1042
-	 * @param  string $context View or edit context.
1043
-	 * @return string
1044
-	 */
1045
-	public function get_customer_country( $context = 'view' ) {
1046
-		return $this->get_country( $context );
1084
+     * Get the customer's city.
1085
+     *
1086
+     * @since 1.0.19
1087
+     * @param  string $context View or edit context.
1088
+     * @return string
1089
+     */
1090
+    public function get_city( $context = 'view' ) {
1091
+        return $this->get_prop( 'city', $context );
1047 1092
     }
1048 1093
 
1049 1094
     /**
1050
-	 * Get the customer's state.
1051
-	 *
1052
-	 * @since 1.0.19
1053
-	 * @param  string $context View or edit context.
1054
-	 * @return string
1055
-	 */
1056
-	public function get_state( $context = 'view' ) {
1057
-		$state = $this->get_prop( 'state', $context );
1058
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1095
+     * Alias of self::get_city().
1096
+     *
1097
+     * @since 1.0.19
1098
+     * @param  string $context View or edit context.
1099
+     * @return string
1100
+     */
1101
+    public function get_user_city( $context = 'view' ) {
1102
+        return $this->get_city( $context );
1103
+    }
1104
+
1105
+    /**
1106
+     * Alias of self::get_city().
1107
+     *
1108
+     * @since 1.0.19
1109
+     * @param  string $context View or edit context.
1110
+     * @return string
1111
+     */
1112
+    public function get_customer_city( $context = 'view' ) {
1113
+        return $this->get_city( $context );
1114
+    }
1115
+
1116
+    /**
1117
+     * Get the customer's zip.
1118
+     *
1119
+     * @since 1.0.19
1120
+     * @param  string $context View or edit context.
1121
+     * @return string
1122
+     */
1123
+    public function get_zip( $context = 'view' ) {
1124
+        return $this->get_prop( 'zip', $context );
1125
+    }
1126
+
1127
+    /**
1128
+     * Alias of self::get_zip().
1129
+     *
1130
+     * @since 1.0.19
1131
+     * @param  string $context View or edit context.
1132
+     * @return string
1133
+     */
1134
+    public function get_user_zip( $context = 'view' ) {
1135
+        return $this->get_zip( $context );
1136
+    }
1137
+
1138
+    /**
1139
+     * Alias of self::get_zip().
1140
+     *
1141
+     * @since 1.0.19
1142
+     * @param  string $context View or edit context.
1143
+     * @return string
1144
+     */
1145
+    public function get_customer_zip( $context = 'view' ) {
1146
+        return $this->get_zip( $context );
1147
+    }
1148
+
1149
+    /**
1150
+     * Get the customer's company.
1151
+     *
1152
+     * @since 1.0.19
1153
+     * @param  string $context View or edit context.
1154
+     * @return string
1155
+     */
1156
+    public function get_company( $context = 'view' ) {
1157
+        return $this->get_prop( 'company', $context );
1158
+    }
1159
+
1160
+    /**
1161
+     * Alias of self::get_company().
1162
+     *
1163
+     * @since 1.0.19
1164
+     * @param  string $context View or edit context.
1165
+     * @return string
1166
+     */
1167
+    public function get_user_company( $context = 'view' ) {
1168
+        return $this->get_company( $context );
1169
+    }
1170
+
1171
+    /**
1172
+     * Alias of self::get_company().
1173
+     *
1174
+     * @since 1.0.19
1175
+     * @param  string $context View or edit context.
1176
+     * @return string
1177
+     */
1178
+    public function get_customer_company( $context = 'view' ) {
1179
+        return $this->get_company( $context );
1180
+    }
1181
+
1182
+    /**
1183
+     * Get the customer's company id.
1184
+     *
1185
+     * @since 1.0.19
1186
+     * @param  string $context View or edit context.
1187
+     * @return string
1188
+     */
1189
+    public function get_company_id( $context = 'view' ) {
1190
+        return $this->get_prop( 'company_id', $context );
1191
+    }
1192
+
1193
+    /**
1194
+     * Get the customer's vat number.
1195
+     *
1196
+     * @since 1.0.19
1197
+     * @param  string $context View or edit context.
1198
+     * @return string
1199
+     */
1200
+    public function get_vat_number( $context = 'view' ) {
1201
+        return $this->get_prop( 'vat_number', $context );
1059 1202
     }
1060 1203
 
1061 1204
     /**
1062
-	 * Alias of self::get_state().
1063
-	 *
1064
-	 * @since 1.0.19
1065
-	 * @param  string $context View or edit context.
1066
-	 * @return string
1067
-	 */
1068
-	public function get_user_state( $context = 'view' ) {
1069
-		return $this->get_state( $context );
1205
+     * Alias of self::get_vat_number().
1206
+     *
1207
+     * @since 1.0.19
1208
+     * @param  string $context View or edit context.
1209
+     * @return string
1210
+     */
1211
+    public function get_user_vat_number( $context = 'view' ) {
1212
+        return $this->get_vat_number( $context );
1070 1213
     }
1071 1214
 
1072 1215
     /**
1073
-	 * Alias of self::get_state().
1074
-	 *
1075
-	 * @since 1.0.19
1076
-	 * @param  string $context View or edit context.
1077
-	 * @return string
1078
-	 */
1079
-	public function get_customer_state( $context = 'view' ) {
1080
-		return $this->get_state( $context );
1216
+     * Alias of self::get_vat_number().
1217
+     *
1218
+     * @since 1.0.19
1219
+     * @param  string $context View or edit context.
1220
+     * @return string
1221
+     */
1222
+    public function get_customer_vat_number( $context = 'view' ) {
1223
+        return $this->get_vat_number( $context );
1081 1224
     }
1082 1225
 
1083 1226
     /**
1084
-	 * Get the customer's city.
1085
-	 *
1086
-	 * @since 1.0.19
1087
-	 * @param  string $context View or edit context.
1088
-	 * @return string
1089
-	 */
1090
-	public function get_city( $context = 'view' ) {
1091
-		return $this->get_prop( 'city', $context );
1227
+     * Get the customer's vat rate.
1228
+     *
1229
+     * @since 1.0.19
1230
+     * @param  string $context View or edit context.
1231
+     * @return string
1232
+     */
1233
+    public function get_vat_rate( $context = 'view' ) {
1234
+        return $this->get_prop( 'vat_rate', $context );
1092 1235
     }
1093 1236
 
1094 1237
     /**
1095
-	 * Alias of self::get_city().
1096
-	 *
1097
-	 * @since 1.0.19
1098
-	 * @param  string $context View or edit context.
1099
-	 * @return string
1100
-	 */
1101
-	public function get_user_city( $context = 'view' ) {
1102
-		return $this->get_city( $context );
1238
+     * Alias of self::get_vat_rate().
1239
+     *
1240
+     * @since 1.0.19
1241
+     * @param  string $context View or edit context.
1242
+     * @return string
1243
+     */
1244
+    public function get_user_vat_rate( $context = 'view' ) {
1245
+        return $this->get_vat_rate( $context );
1103 1246
     }
1104 1247
 
1105 1248
     /**
1106
-	 * Alias of self::get_city().
1107
-	 *
1108
-	 * @since 1.0.19
1109
-	 * @param  string $context View or edit context.
1110
-	 * @return string
1111
-	 */
1112
-	public function get_customer_city( $context = 'view' ) {
1113
-		return $this->get_city( $context );
1249
+     * Alias of self::get_vat_rate().
1250
+     *
1251
+     * @since 1.0.19
1252
+     * @param  string $context View or edit context.
1253
+     * @return string
1254
+     */
1255
+    public function get_customer_vat_rate( $context = 'view' ) {
1256
+        return $this->get_vat_rate( $context );
1114 1257
     }
1115 1258
 
1116 1259
     /**
1117
-	 * Get the customer's zip.
1118
-	 *
1119
-	 * @since 1.0.19
1120
-	 * @param  string $context View or edit context.
1121
-	 * @return string
1122
-	 */
1123
-	public function get_zip( $context = 'view' ) {
1124
-		return $this->get_prop( 'zip', $context );
1260
+     * Get the customer's address.
1261
+     *
1262
+     * @since 1.0.19
1263
+     * @param  string $context View or edit context.
1264
+     * @return string
1265
+     */
1266
+    public function get_address( $context = 'view' ) {
1267
+        return $this->get_prop( 'address', $context );
1125 1268
     }
1126 1269
 
1127 1270
     /**
1128
-	 * Alias of self::get_zip().
1129
-	 *
1130
-	 * @since 1.0.19
1131
-	 * @param  string $context View or edit context.
1132
-	 * @return string
1133
-	 */
1134
-	public function get_user_zip( $context = 'view' ) {
1135
-		return $this->get_zip( $context );
1271
+     * Alias of self::get_address().
1272
+     *
1273
+     * @since 1.0.19
1274
+     * @param  string $context View or edit context.
1275
+     * @return string
1276
+     */
1277
+    public function get_user_address( $context = 'view' ) {
1278
+        return $this->get_address( $context );
1136 1279
     }
1137 1280
 
1138 1281
     /**
1139
-	 * Alias of self::get_zip().
1140
-	 *
1141
-	 * @since 1.0.19
1142
-	 * @param  string $context View or edit context.
1143
-	 * @return string
1144
-	 */
1145
-	public function get_customer_zip( $context = 'view' ) {
1146
-		return $this->get_zip( $context );
1282
+     * Alias of self::get_address().
1283
+     *
1284
+     * @since 1.0.19
1285
+     * @param  string $context View or edit context.
1286
+     * @return string
1287
+     */
1288
+    public function get_customer_address( $context = 'view' ) {
1289
+        return $this->get_address( $context );
1147 1290
     }
1148 1291
 
1149 1292
     /**
1150
-	 * Get the customer's company.
1151
-	 *
1152
-	 * @since 1.0.19
1153
-	 * @param  string $context View or edit context.
1154
-	 * @return string
1155
-	 */
1156
-	public function get_company( $context = 'view' ) {
1157
-		return $this->get_prop( 'company', $context );
1293
+     * Get whether the customer has viewed the invoice or not.
1294
+     *
1295
+     * @since 1.0.19
1296
+     * @param  string $context View or edit context.
1297
+     * @return bool
1298
+     */
1299
+    public function get_is_viewed( $context = 'view' ) {
1300
+        return (bool) $this->get_prop( 'is_viewed', $context );
1158 1301
     }
1159 1302
 
1160 1303
     /**
1161
-	 * Alias of self::get_company().
1162
-	 *
1163
-	 * @since 1.0.19
1164
-	 * @param  string $context View or edit context.
1165
-	 * @return string
1166
-	 */
1167
-	public function get_user_company( $context = 'view' ) {
1168
-		return $this->get_company( $context );
1304
+     * Get other recipients for invoice communications.
1305
+     *
1306
+     * @since 1.0.19
1307
+     * @param  string $context View or edit context.
1308
+     * @return bool
1309
+     */
1310
+    public function get_email_cc( $context = 'view' ) {
1311
+        return $this->get_prop( 'email_cc', $context );
1169 1312
     }
1170 1313
 
1171 1314
     /**
1172
-	 * Alias of self::get_company().
1173
-	 *
1174
-	 * @since 1.0.19
1175
-	 * @param  string $context View or edit context.
1176
-	 * @return string
1177
-	 */
1178
-	public function get_customer_company( $context = 'view' ) {
1179
-		return $this->get_company( $context );
1315
+     * Get invoice template.
1316
+     *
1317
+     * @since 1.0.19
1318
+     * @param  string $context View or edit context.
1319
+     * @return bool
1320
+     */
1321
+    public function get_template( $context = 'view' ) {
1322
+        return $this->get_prop( 'template', $context );
1180 1323
     }
1181 1324
 
1182
-	/**
1183
-	 * Get the customer's company id.
1184
-	 *
1185
-	 * @since 1.0.19
1186
-	 * @param  string $context View or edit context.
1187
-	 * @return string
1188
-	 */
1189
-	public function get_company_id( $context = 'view' ) {
1190
-		return $this->get_prop( 'company_id', $context );
1325
+    /**
1326
+     * Get invoice source.
1327
+     *
1328
+     * @since 1.0.19
1329
+     * @param  string $context View or edit context.
1330
+     * @return bool
1331
+     */
1332
+    public function get_created_via( $context = 'view' ) {
1333
+        return $this->get_prop( 'created_via', $context );
1191 1334
     }
1192 1335
 
1193 1336
     /**
1194
-	 * Get the customer's vat number.
1195
-	 *
1196
-	 * @since 1.0.19
1197
-	 * @param  string $context View or edit context.
1198
-	 * @return string
1199
-	 */
1200
-	public function get_vat_number( $context = 'view' ) {
1201
-		return $this->get_prop( 'vat_number', $context );
1337
+     * Get whether the customer has confirmed their address.
1338
+     *
1339
+     * @since 1.0.19
1340
+     * @param  string $context View or edit context.
1341
+     * @return bool
1342
+     */
1343
+    public function get_address_confirmed( $context = 'view' ) {
1344
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1202 1345
     }
1203 1346
 
1204 1347
     /**
1205
-	 * Alias of self::get_vat_number().
1206
-	 *
1207
-	 * @since 1.0.19
1208
-	 * @param  string $context View or edit context.
1209
-	 * @return string
1210
-	 */
1211
-	public function get_user_vat_number( $context = 'view' ) {
1212
-		return $this->get_vat_number( $context );
1348
+     * Alias of self::get_address_confirmed().
1349
+     *
1350
+     * @since 1.0.19
1351
+     * @param  string $context View or edit context.
1352
+     * @return bool
1353
+     */
1354
+    public function get_user_address_confirmed( $context = 'view' ) {
1355
+        return $this->get_address_confirmed( $context );
1213 1356
     }
1214 1357
 
1215 1358
     /**
1216
-	 * Alias of self::get_vat_number().
1217
-	 *
1218
-	 * @since 1.0.19
1219
-	 * @param  string $context View or edit context.
1220
-	 * @return string
1221
-	 */
1222
-	public function get_customer_vat_number( $context = 'view' ) {
1223
-		return $this->get_vat_number( $context );
1359
+     * Alias of self::get_address().
1360
+     *
1361
+     * @since 1.0.19
1362
+     * @param  string $context View or edit context.
1363
+     * @return bool
1364
+     */
1365
+    public function get_customer_address_confirmed( $context = 'view' ) {
1366
+        return $this->get_address_confirmed( $context );
1224 1367
     }
1225 1368
 
1226
-    /**
1227
-	 * Get the customer's vat rate.
1228
-	 *
1229
-	 * @since 1.0.19
1230
-	 * @param  string $context View or edit context.
1231
-	 * @return string
1232
-	 */
1233
-	public function get_vat_rate( $context = 'view' ) {
1234
-		return $this->get_prop( 'vat_rate', $context );
1235
-    }
1236
-
1237
-    /**
1238
-	 * Alias of self::get_vat_rate().
1239
-	 *
1240
-	 * @since 1.0.19
1241
-	 * @param  string $context View or edit context.
1242
-	 * @return string
1243
-	 */
1244
-	public function get_user_vat_rate( $context = 'view' ) {
1245
-		return $this->get_vat_rate( $context );
1246
-    }
1247
-
1248
-    /**
1249
-	 * Alias of self::get_vat_rate().
1250
-	 *
1251
-	 * @since 1.0.19
1252
-	 * @param  string $context View or edit context.
1253
-	 * @return string
1254
-	 */
1255
-	public function get_customer_vat_rate( $context = 'view' ) {
1256
-		return $this->get_vat_rate( $context );
1257
-    }
1258
-
1259
-    /**
1260
-	 * Get the customer's address.
1261
-	 *
1262
-	 * @since 1.0.19
1263
-	 * @param  string $context View or edit context.
1264
-	 * @return string
1265
-	 */
1266
-	public function get_address( $context = 'view' ) {
1267
-		return $this->get_prop( 'address', $context );
1268
-    }
1269
-
1270
-    /**
1271
-	 * Alias of self::get_address().
1272
-	 *
1273
-	 * @since 1.0.19
1274
-	 * @param  string $context View or edit context.
1275
-	 * @return string
1276
-	 */
1277
-	public function get_user_address( $context = 'view' ) {
1278
-		return $this->get_address( $context );
1279
-    }
1280
-
1281
-    /**
1282
-	 * Alias of self::get_address().
1283
-	 *
1284
-	 * @since 1.0.19
1285
-	 * @param  string $context View or edit context.
1286
-	 * @return string
1287
-	 */
1288
-	public function get_customer_address( $context = 'view' ) {
1289
-		return $this->get_address( $context );
1290
-    }
1291
-
1292
-    /**
1293
-	 * Get whether the customer has viewed the invoice or not.
1294
-	 *
1295
-	 * @since 1.0.19
1296
-	 * @param  string $context View or edit context.
1297
-	 * @return bool
1298
-	 */
1299
-	public function get_is_viewed( $context = 'view' ) {
1300
-		return (bool) $this->get_prop( 'is_viewed', $context );
1301
-	}
1302
-
1303
-	/**
1304
-	 * Get other recipients for invoice communications.
1305
-	 *
1306
-	 * @since 1.0.19
1307
-	 * @param  string $context View or edit context.
1308
-	 * @return bool
1309
-	 */
1310
-	public function get_email_cc( $context = 'view' ) {
1311
-		return $this->get_prop( 'email_cc', $context );
1312
-	}
1313
-
1314
-	/**
1315
-	 * Get invoice template.
1316
-	 *
1317
-	 * @since 1.0.19
1318
-	 * @param  string $context View or edit context.
1319
-	 * @return bool
1320
-	 */
1321
-	public function get_template( $context = 'view' ) {
1322
-		return $this->get_prop( 'template', $context );
1323
-	}
1324
-
1325
-	/**
1326
-	 * Get invoice source.
1327
-	 *
1328
-	 * @since 1.0.19
1329
-	 * @param  string $context View or edit context.
1330
-	 * @return bool
1331
-	 */
1332
-	public function get_created_via( $context = 'view' ) {
1333
-		return $this->get_prop( 'created_via', $context );
1334
-	}
1335
-
1336
-	/**
1337
-	 * Get whether the customer has confirmed their address.
1338
-	 *
1339
-	 * @since 1.0.19
1340
-	 * @param  string $context View or edit context.
1341
-	 * @return bool
1342
-	 */
1343
-	public function get_address_confirmed( $context = 'view' ) {
1344
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1345
-    }
1346
-
1347
-    /**
1348
-	 * Alias of self::get_address_confirmed().
1349
-	 *
1350
-	 * @since 1.0.19
1351
-	 * @param  string $context View or edit context.
1352
-	 * @return bool
1353
-	 */
1354
-	public function get_user_address_confirmed( $context = 'view' ) {
1355
-		return $this->get_address_confirmed( $context );
1356
-    }
1357
-
1358
-    /**
1359
-	 * Alias of self::get_address().
1360
-	 *
1361
-	 * @since 1.0.19
1362
-	 * @param  string $context View or edit context.
1363
-	 * @return bool
1364
-	 */
1365
-	public function get_customer_address_confirmed( $context = 'view' ) {
1366
-		return $this->get_address_confirmed( $context );
1367
-    }
1368
-
1369
-    /**
1370
-	 * Get the invoice subtotal.
1371
-	 *
1372
-	 * @since 1.0.19
1373
-	 * @param  string $context View or edit context.
1374
-	 * @return float
1375
-	 */
1376
-	public function get_subtotal( $context = 'view' ) {
1369
+    /**
1370
+     * Get the invoice subtotal.
1371
+     *
1372
+     * @since 1.0.19
1373
+     * @param  string $context View or edit context.
1374
+     * @return float
1375
+     */
1376
+    public function get_subtotal( $context = 'view' ) {
1377 1377
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1378 1378
 
1379 1379
         // Backwards compatibility.
@@ -1385,192 +1385,192 @@  discard block
 block discarded – undo
1385 1385
     }
1386 1386
 
1387 1387
     /**
1388
-	 * Get the invoice discount total.
1389
-	 *
1390
-	 * @since 1.0.19
1391
-	 * @param  string $context View or edit context.
1392
-	 * @return float
1393
-	 */
1394
-	public function get_total_discount( $context = 'view' ) {
1395
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1388
+     * Get the invoice discount total.
1389
+     *
1390
+     * @since 1.0.19
1391
+     * @param  string $context View or edit context.
1392
+     * @return float
1393
+     */
1394
+    public function get_total_discount( $context = 'view' ) {
1395
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1396 1396
     }
1397 1397
 
1398 1398
     /**
1399
-	 * Get the invoice tax total.
1400
-	 *
1401
-	 * @since 1.0.19
1402
-	 * @param  string $context View or edit context.
1403
-	 * @return float
1404
-	 */
1405
-	public function get_total_tax( $context = 'view' ) {
1406
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1407
-	}
1399
+     * Get the invoice tax total.
1400
+     *
1401
+     * @since 1.0.19
1402
+     * @param  string $context View or edit context.
1403
+     * @return float
1404
+     */
1405
+    public function get_total_tax( $context = 'view' ) {
1406
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1407
+    }
1408 1408
 
1409
-	/**
1410
-	 * @deprecated
1411
-	 */
1412
-	public function get_final_tax( $currency = false ) {
1413
-		$tax = $this->get_total_tax();
1409
+    /**
1410
+     * @deprecated
1411
+     */
1412
+    public function get_final_tax( $currency = false ) {
1413
+        $tax = $this->get_total_tax();
1414 1414
 
1415 1415
         if ( $currency ) {
1416
-			return wpinv_price( $tax, $this->get_currency() );
1416
+            return wpinv_price( $tax, $this->get_currency() );
1417 1417
         }
1418 1418
 
1419 1419
         return $tax;
1420 1420
     }
1421 1421
 
1422 1422
     /**
1423
-	 * Get the invoice fees total.
1424
-	 *
1425
-	 * @since 1.0.19
1426
-	 * @param  string $context View or edit context.
1427
-	 * @return float
1428
-	 */
1429
-	public function get_total_fees( $context = 'view' ) {
1430
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1423
+     * Get the invoice fees total.
1424
+     *
1425
+     * @since 1.0.19
1426
+     * @param  string $context View or edit context.
1427
+     * @return float
1428
+     */
1429
+    public function get_total_fees( $context = 'view' ) {
1430
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1431 1431
     }
1432 1432
 
1433 1433
     /**
1434
-	 * Alias for self::get_total_fees().
1435
-	 *
1436
-	 * @since 1.0.19
1437
-	 * @param  string $context View or edit context.
1438
-	 * @return float
1439
-	 */
1440
-	public function get_fees_total( $context = 'view' ) {
1441
-		return $this->get_total_fees( $context );
1434
+     * Alias for self::get_total_fees().
1435
+     *
1436
+     * @since 1.0.19
1437
+     * @param  string $context View or edit context.
1438
+     * @return float
1439
+     */
1440
+    public function get_fees_total( $context = 'view' ) {
1441
+        return $this->get_total_fees( $context );
1442 1442
     }
1443 1443
 
1444 1444
     /**
1445
-	 * Get the invoice total.
1446
-	 *
1447
-	 * @since 1.0.19
1445
+     * Get the invoice total.
1446
+     *
1447
+     * @since 1.0.19
1448 1448
      * @return float
1449
-	 */
1450
-	public function get_total( $context = 'view' ) {
1451
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) );
1452
-	}
1453
-
1454
-	/**
1455
-	 * Retrieves the non-recurring total of items.
1456
-	 *
1457
-	 * @since 2.3.0
1458
-	 * @return float
1459
-	 */
1460
-	public function get_non_recurring_total() {
1461
-
1462
-		$subtotal = 0;
1463
-		foreach ( $this->get_items() as $item ) {
1464
-			if ( ! $item->is_recurring() ) {
1465
-				$subtotal += $item->get_sub_total();
1466
-			}
1467
-		}
1468
-
1469
-		foreach ( $this->get_fees() as $fee ) {
1470
-			if ( empty( $fee['recurring_fee'] ) ) {
1471
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1472
-			}
1473
-		}
1474
-
1475
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1449
+     */
1450
+    public function get_total( $context = 'view' ) {
1451
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total', $context ) ) );
1452
+    }
1453
+
1454
+    /**
1455
+     * Retrieves the non-recurring total of items.
1456
+     *
1457
+     * @since 2.3.0
1458
+     * @return float
1459
+     */
1460
+    public function get_non_recurring_total() {
1461
+
1462
+        $subtotal = 0;
1463
+        foreach ( $this->get_items() as $item ) {
1464
+            if ( ! $item->is_recurring() ) {
1465
+                $subtotal += $item->get_sub_total();
1466
+            }
1467
+        }
1468
+
1469
+        foreach ( $this->get_fees() as $fee ) {
1470
+            if ( empty( $fee['recurring_fee'] ) ) {
1471
+                $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1472
+            }
1473
+        }
1474
+
1475
+        $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1476 1476
         return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1477 1477
 
1478 1478
     }
1479 1479
 
1480
-	/**
1481
-	 * Get the invoice totals.
1482
-	 *
1483
-	 * @since 1.0.19
1480
+    /**
1481
+     * Get the invoice totals.
1482
+     *
1483
+     * @since 1.0.19
1484 1484
      * @return array
1485
-	 */
1486
-	public function get_totals() {
1487
-		return $this->totals;
1485
+     */
1486
+    public function get_totals() {
1487
+        return $this->totals;
1488 1488
     }
1489 1489
 
1490 1490
     /**
1491
-	 * Get the initial invoice total.
1492
-	 *
1493
-	 * @since 1.0.19
1491
+     * Get the initial invoice total.
1492
+     *
1493
+     * @since 1.0.19
1494 1494
      * @param  string $context View or edit context.
1495 1495
      * @return float
1496
-	 */
1496
+     */
1497 1497
     public function get_initial_total() {
1498 1498
 
1499
-		if ( empty( $this->totals ) ) {
1500
-			$this->recalculate_total();
1501
-		}
1499
+        if ( empty( $this->totals ) ) {
1500
+            $this->recalculate_total();
1501
+        }
1502 1502
 
1503
-		$tax      = $this->totals['tax']['initial'];
1504
-		$fee      = $this->totals['fee']['initial'];
1505
-		$discount = $this->totals['discount']['initial'];
1506
-		$subtotal = $this->totals['subtotal']['initial'];
1507
-		$total    = $tax + $fee - $discount + $subtotal;
1503
+        $tax      = $this->totals['tax']['initial'];
1504
+        $fee      = $this->totals['fee']['initial'];
1505
+        $discount = $this->totals['discount']['initial'];
1506
+        $subtotal = $this->totals['subtotal']['initial'];
1507
+        $total    = $tax + $fee - $discount + $subtotal;
1508 1508
 
1509
-		if ( 0 > $total ) {
1510
-			$total = 0;
1511
-		}
1509
+        if ( 0 > $total ) {
1510
+            $total = 0;
1511
+        }
1512 1512
 
1513
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1513
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1514 1514
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1515
-	}
1515
+    }
1516 1516
 
1517
-	/**
1518
-	 * Get the recurring invoice total.
1519
-	 *
1520
-	 * @since 1.0.19
1517
+    /**
1518
+     * Get the recurring invoice total.
1519
+     *
1520
+     * @since 1.0.19
1521 1521
      * @param  string $context View or edit context.
1522 1522
      * @return float
1523
-	 */
1523
+     */
1524 1524
     public function get_recurring_total() {
1525 1525
 
1526
-		if ( empty( $this->totals ) ) {
1527
-			$this->recalculate_total();
1528
-		}
1526
+        if ( empty( $this->totals ) ) {
1527
+            $this->recalculate_total();
1528
+        }
1529 1529
 
1530
-		$tax      = $this->totals['tax']['recurring'];
1531
-		$fee      = $this->totals['fee']['recurring'];
1532
-		$discount = $this->totals['discount']['recurring'];
1533
-		$subtotal = $this->totals['subtotal']['recurring'];
1534
-		$total    = $tax + $fee - $discount + $subtotal;
1530
+        $tax      = $this->totals['tax']['recurring'];
1531
+        $fee      = $this->totals['fee']['recurring'];
1532
+        $discount = $this->totals['discount']['recurring'];
1533
+        $subtotal = $this->totals['subtotal']['recurring'];
1534
+        $total    = $tax + $fee - $discount + $subtotal;
1535 1535
 
1536
-		if ( 0 > $total ) {
1537
-			$total = 0;
1538
-		}
1536
+        if ( 0 > $total ) {
1537
+            $total = 0;
1538
+        }
1539 1539
 
1540
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1540
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1541 1541
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1542
-	}
1542
+    }
1543 1543
 
1544
-	/**
1545
-	 * Returns recurring payment details.
1546
-	 *
1547
-	 * @since 1.0.19
1544
+    /**
1545
+     * Returns recurring payment details.
1546
+     *
1547
+     * @since 1.0.19
1548 1548
      * @param  string $field Optionally provide a field to return.
1549
-	 * @param string $currency Whether to include the currency.
1549
+     * @param string $currency Whether to include the currency.
1550 1550
      * @return float|string
1551
-	 */
1551
+     */
1552 1552
     public function get_recurring_details( $field = '', $currency = false ) {
1553 1553
 
1554
-		// Maybe recalculate totals.
1555
-		if ( empty( $this->totals ) ) {
1556
-			$this->recalculate_total();
1557
-		}
1554
+        // Maybe recalculate totals.
1555
+        if ( empty( $this->totals ) ) {
1556
+            $this->recalculate_total();
1557
+        }
1558 1558
 
1559
-		// Prepare recurring totals.
1559
+        // Prepare recurring totals.
1560 1560
         $data = apply_filters(
1561
-			'wpinv_get_invoice_recurring_details',
1562
-			array(
1563
-				'cart_details' => $this->get_cart_details(),
1564
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1565
-				'discount'     => $this->totals['discount']['recurring'],
1566
-				'tax'          => $this->totals['tax']['recurring'],
1567
-				'fee'          => $this->totals['fee']['recurring'],
1568
-				'total'        => $this->get_recurring_total(),
1569
-			),
1570
-			$this,
1571
-			$field,
1572
-			$currency
1573
-		);
1561
+            'wpinv_get_invoice_recurring_details',
1562
+            array(
1563
+                'cart_details' => $this->get_cart_details(),
1564
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1565
+                'discount'     => $this->totals['discount']['recurring'],
1566
+                'tax'          => $this->totals['tax']['recurring'],
1567
+                'fee'          => $this->totals['fee']['recurring'],
1568
+                'total'        => $this->get_recurring_total(),
1569
+            ),
1570
+            $this,
1571
+            $field,
1572
+            $currency
1573
+        );
1574 1574
 
1575 1575
         if ( isset( $data[$field] ) ) {
1576 1576
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1580,166 +1580,166 @@  discard block
 block discarded – undo
1580 1580
     }
1581 1581
 
1582 1582
     /**
1583
-	 * Get the invoice fees.
1584
-	 *
1585
-	 * @since 1.0.19
1586
-	 * @param  string $context View or edit context.
1587
-	 * @return array
1588
-	 */
1589
-	public function get_fees( $context = 'view' ) {
1590
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1583
+     * Get the invoice fees.
1584
+     *
1585
+     * @since 1.0.19
1586
+     * @param  string $context View or edit context.
1587
+     * @return array
1588
+     */
1589
+    public function get_fees( $context = 'view' ) {
1590
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1591
+    }
1592
+
1593
+    /**
1594
+     * Get the invoice discounts.
1595
+     *
1596
+     * @since 1.0.19
1597
+     * @param  string $context View or edit context.
1598
+     * @return array
1599
+     */
1600
+    public function get_discounts( $context = 'view' ) {
1601
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1591 1602
     }
1592 1603
 
1593 1604
     /**
1594
-	 * Get the invoice discounts.
1595
-	 *
1596
-	 * @since 1.0.19
1597
-	 * @param  string $context View or edit context.
1598
-	 * @return array
1599
-	 */
1600
-	public function get_discounts( $context = 'view' ) {
1601
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1605
+     * Get the invoice taxes.
1606
+     *
1607
+     * @since 1.0.19
1608
+     * @param  string $context View or edit context.
1609
+     * @return array
1610
+     */
1611
+    public function get_taxes( $context = 'view' ) {
1612
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1602 1613
     }
1603 1614
 
1604 1615
     /**
1605
-	 * Get the invoice taxes.
1606
-	 *
1607
-	 * @since 1.0.19
1608
-	 * @param  string $context View or edit context.
1609
-	 * @return array
1610
-	 */
1611
-	public function get_taxes( $context = 'view' ) {
1612
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1616
+     * Get the invoice items.
1617
+     *
1618
+     * @since 1.0.19
1619
+     * @param  string $context View or edit context.
1620
+     * @return GetPaid_Form_Item[]
1621
+     */
1622
+    public function get_items( $context = 'view' ) {
1623
+        return $this->get_prop( 'items', $context );
1613 1624
     }
1614 1625
 
1615 1626
     /**
1616
-	 * Get the invoice items.
1617
-	 *
1618
-	 * @since 1.0.19
1619
-	 * @param  string $context View or edit context.
1620
-	 * @return GetPaid_Form_Item[]
1621
-	 */
1622
-	public function get_items( $context = 'view' ) {
1623
-        return $this->get_prop( 'items', $context );
1624
-	}
1625
-
1626
-	/**
1627
-	 * Get the invoice item ids.
1628
-	 *
1629
-	 * @since 1.0.19
1630
-	 * @return string
1631
-	 */
1632
-	public function get_item_ids() {
1633
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1627
+     * Get the invoice item ids.
1628
+     *
1629
+     * @since 1.0.19
1630
+     * @return string
1631
+     */
1632
+    public function get_item_ids() {
1633
+        return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1634 1634
     }
1635 1635
 
1636 1636
     /**
1637
-	 * Get the invoice's payment form.
1638
-	 *
1639
-	 * @since 1.0.19
1640
-	 * @param  string $context View or edit context.
1641
-	 * @return int
1642
-	 */
1643
-	public function get_payment_form( $context = 'view' ) {
1644
-		return intval( $this->get_prop( 'payment_form', $context ) );
1637
+     * Get the invoice's payment form.
1638
+     *
1639
+     * @since 1.0.19
1640
+     * @param  string $context View or edit context.
1641
+     * @return int
1642
+     */
1643
+    public function get_payment_form( $context = 'view' ) {
1644
+        return intval( $this->get_prop( 'payment_form', $context ) );
1645 1645
     }
1646 1646
 
1647 1647
     /**
1648
-	 * Get the invoice's submission id.
1649
-	 *
1650
-	 * @since 1.0.19
1651
-	 * @param  string $context View or edit context.
1652
-	 * @return string
1653
-	 */
1654
-	public function get_submission_id( $context = 'view' ) {
1655
-		return $this->get_prop( 'submission_id', $context );
1648
+     * Get the invoice's submission id.
1649
+     *
1650
+     * @since 1.0.19
1651
+     * @param  string $context View or edit context.
1652
+     * @return string
1653
+     */
1654
+    public function get_submission_id( $context = 'view' ) {
1655
+        return $this->get_prop( 'submission_id', $context );
1656 1656
     }
1657 1657
 
1658 1658
     /**
1659
-	 * Get the invoice's discount code.
1660
-	 *
1661
-	 * @since 1.0.19
1662
-	 * @param  string $context View or edit context.
1663
-	 * @return string
1664
-	 */
1665
-	public function get_discount_code( $context = 'view' ) {
1666
-		return $this->get_prop( 'discount_code', $context );
1659
+     * Get the invoice's discount code.
1660
+     *
1661
+     * @since 1.0.19
1662
+     * @param  string $context View or edit context.
1663
+     * @return string
1664
+     */
1665
+    public function get_discount_code( $context = 'view' ) {
1666
+        return $this->get_prop( 'discount_code', $context );
1667 1667
     }
1668 1668
 
1669 1669
     /**
1670
-	 * Get the invoice's gateway.
1671
-	 *
1672
-	 * @since 1.0.19
1673
-	 * @param  string $context View or edit context.
1674
-	 * @return string
1675
-	 */
1676
-	public function get_gateway( $context = 'view' ) {
1677
-		return $this->get_prop( 'gateway', $context );
1670
+     * Get the invoice's gateway.
1671
+     *
1672
+     * @since 1.0.19
1673
+     * @param  string $context View or edit context.
1674
+     * @return string
1675
+     */
1676
+    public function get_gateway( $context = 'view' ) {
1677
+        return $this->get_prop( 'gateway', $context );
1678 1678
     }
1679 1679
 
1680 1680
     /**
1681
-	 * Get the invoice's gateway display title.
1682
-	 *
1683
-	 * @since 1.0.19
1684
-	 * @return string
1685
-	 */
1681
+     * Get the invoice's gateway display title.
1682
+     *
1683
+     * @since 1.0.19
1684
+     * @return string
1685
+     */
1686 1686
     public function get_gateway_title() {
1687 1687
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1688 1688
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1689 1689
     }
1690 1690
 
1691 1691
     /**
1692
-	 * Get the invoice's transaction id.
1693
-	 *
1694
-	 * @since 1.0.19
1695
-	 * @param  string $context View or edit context.
1696
-	 * @return string
1697
-	 */
1698
-	public function get_transaction_id( $context = 'view' ) {
1699
-		return $this->get_prop( 'transaction_id', $context );
1692
+     * Get the invoice's transaction id.
1693
+     *
1694
+     * @since 1.0.19
1695
+     * @param  string $context View or edit context.
1696
+     * @return string
1697
+     */
1698
+    public function get_transaction_id( $context = 'view' ) {
1699
+        return $this->get_prop( 'transaction_id', $context );
1700 1700
     }
1701 1701
 
1702 1702
     /**
1703
-	 * Get the invoice's currency.
1704
-	 *
1705
-	 * @since 1.0.19
1706
-	 * @param  string $context View or edit context.
1707
-	 * @return string
1708
-	 */
1709
-	public function get_currency( $context = 'view' ) {
1703
+     * Get the invoice's currency.
1704
+     *
1705
+     * @since 1.0.19
1706
+     * @param  string $context View or edit context.
1707
+     * @return string
1708
+     */
1709
+    public function get_currency( $context = 'view' ) {
1710 1710
         $currency = $this->get_prop( 'currency', $context );
1711 1711
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1712 1712
     }
1713 1713
 
1714 1714
     /**
1715
-	 * Checks if we are charging taxes for this invoice.
1716
-	 *
1717
-	 * @since 1.0.19
1718
-	 * @param  string $context View or edit context.
1719
-	 * @return bool
1720
-	 */
1721
-	public function get_disable_taxes( $context = 'view' ) {
1715
+     * Checks if we are charging taxes for this invoice.
1716
+     *
1717
+     * @since 1.0.19
1718
+     * @param  string $context View or edit context.
1719
+     * @return bool
1720
+     */
1721
+    public function get_disable_taxes( $context = 'view' ) {
1722 1722
         return (bool) $this->get_prop( 'disable_taxes', $context );
1723 1723
     }
1724 1724
 
1725 1725
     /**
1726
-	 * Retrieves the subscription id for an invoice.
1727
-	 *
1728
-	 * @since 1.0.19
1729
-	 * @param  string $context View or edit context.
1730
-	 * @return int
1731
-	 */
1726
+     * Retrieves the subscription id for an invoice.
1727
+     *
1728
+     * @since 1.0.19
1729
+     * @param  string $context View or edit context.
1730
+     * @return int
1731
+     */
1732 1732
     public function get_subscription_id( $context = 'view' ) {
1733
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1734
-	}
1735
-
1736
-	/**
1737
-	 * Retrieves the remote subscription id for an invoice.
1738
-	 *
1739
-	 * @since 1.0.19
1740
-	 * @param  string $context View or edit context.
1741
-	 * @return int
1742
-	 */
1733
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1734
+    }
1735
+
1736
+    /**
1737
+     * Retrieves the remote subscription id for an invoice.
1738
+     *
1739
+     * @since 1.0.19
1740
+     * @param  string $context View or edit context.
1741
+     * @return int
1742
+     */
1743 1743
     public function get_remote_subscription_id( $context = 'view' ) {
1744 1744
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1745 1745
 
@@ -1752,12 +1752,12 @@  discard block
 block discarded – undo
1752 1752
     }
1753 1753
 
1754 1754
     /**
1755
-	 * Retrieves the payment meta for an invoice.
1756
-	 *
1757
-	 * @since 1.0.19
1758
-	 * @param  string $context View or edit context.
1759
-	 * @return array
1760
-	 */
1755
+     * Retrieves the payment meta for an invoice.
1756
+     *
1757
+     * @since 1.0.19
1758
+     * @param  string $context View or edit context.
1759
+     * @return array
1760
+     */
1761 1761
     public function get_payment_meta( $context = 'view' ) {
1762 1762
 
1763 1763
         return array(
@@ -1777,31 +1777,31 @@  discard block
 block discarded – undo
1777 1777
     }
1778 1778
 
1779 1779
     /**
1780
-	 * Retrieves the cart details for an invoice.
1781
-	 *
1782
-	 * @since 1.0.19
1783
-	 * @return array
1784
-	 */
1780
+     * Retrieves the cart details for an invoice.
1781
+     *
1782
+     * @since 1.0.19
1783
+     * @return array
1784
+     */
1785 1785
     public function get_cart_details() {
1786 1786
         $items        = $this->get_items();
1787 1787
         $cart_details = array();
1788 1788
 
1789 1789
         foreach ( $items as $item ) {
1790
-			$item->invoice_id = $this->get_id();
1790
+            $item->invoice_id = $this->get_id();
1791 1791
             $cart_details[]   = $item->prepare_data_for_saving();
1792 1792
         }
1793 1793
 
1794 1794
         return $cart_details;
1795
-	}
1795
+    }
1796 1796
 
1797
-	/**
1798
-	 * Retrieves the recurring item.
1799
-	 *
1800
-	 * @return null|GetPaid_Form_Item|int
1801
-	 */
1802
-	public function get_recurring( $object = false ) {
1797
+    /**
1798
+     * Retrieves the recurring item.
1799
+     *
1800
+     * @return null|GetPaid_Form_Item|int
1801
+     */
1802
+    public function get_recurring( $object = false ) {
1803 1803
 
1804
-		// Are we returning an object?
1804
+        // Are we returning an object?
1805 1805
         if ( $object ) {
1806 1806
             return $this->get_item( $this->recurring_item );
1807 1807
         }
@@ -1809,114 +1809,114 @@  discard block
 block discarded – undo
1809 1809
         return $this->recurring_item;
1810 1810
     }
1811 1811
 
1812
-	/**
1813
-	 * Retrieves the subscription name.
1814
-	 *
1815
-	 * @since 1.0.19
1816
-	 * @return string
1817
-	 */
1818
-	public function get_subscription_name() {
1812
+    /**
1813
+     * Retrieves the subscription name.
1814
+     *
1815
+     * @since 1.0.19
1816
+     * @return string
1817
+     */
1818
+    public function get_subscription_name() {
1819 1819
 
1820
-		// Retrieve the recurring name
1820
+        // Retrieve the recurring name
1821 1821
         $item = $this->get_recurring( true );
1822 1822
 
1823
-		// Abort if it does not exist.
1823
+        // Abort if it does not exist.
1824 1824
         if ( empty( $item ) ) {
1825 1825
             return '';
1826 1826
         }
1827 1827
 
1828
-		// Return the item name.
1828
+        // Return the item name.
1829 1829
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1830
-	}
1831
-
1832
-	/**
1833
-	 * Retrieves the view url.
1834
-	 *
1835
-	 * @since 1.0.19
1836
-	 * @return string
1837
-	 */
1838
-	public function get_view_url() {
1830
+    }
1831
+
1832
+    /**
1833
+     * Retrieves the view url.
1834
+     *
1835
+     * @since 1.0.19
1836
+     * @return string
1837
+     */
1838
+    public function get_view_url() {
1839 1839
         $invoice_url = get_permalink( $this->get_id() );
1840
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1840
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1841 1841
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1842
-	}
1842
+    }
1843 1843
 
1844
-	/**
1845
-	 * Retrieves the payment url.
1846
-	 *
1847
-	 * @since 1.0.19
1848
-	 * @return string
1849
-	 */
1850
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1844
+    /**
1845
+     * Retrieves the payment url.
1846
+     *
1847
+     * @since 1.0.19
1848
+     * @return string
1849
+     */
1850
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1851 1851
 
1852
-		// Retrieve the checkout url.
1852
+        // Retrieve the checkout url.
1853 1853
         $pay_url = wpinv_get_checkout_uri();
1854 1854
 
1855
-		// Maybe force ssl.
1855
+        // Maybe force ssl.
1856 1856
         if ( is_ssl() ) {
1857 1857
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1858 1858
         }
1859 1859
 
1860
-		// Add the invoice key.
1861
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1860
+        // Add the invoice key.
1861
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1862 1862
 
1863
-		// (Maybe?) add a secret
1863
+        // (Maybe?) add a secret
1864 1864
         if ( $secret ) {
1865 1865
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1866 1866
         }
1867 1867
 
1868 1868
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1869
-	}
1869
+    }
1870 1870
 	
1871
-	/**
1872
-	 * Retrieves the receipt url.
1873
-	 *
1874
-	 * @since 1.0.19
1875
-	 * @return string
1876
-	 */
1877
-	public function get_receipt_url() {
1878
-
1879
-		// Retrieve the checkout url.
1871
+    /**
1872
+     * Retrieves the receipt url.
1873
+     *
1874
+     * @since 1.0.19
1875
+     * @return string
1876
+     */
1877
+    public function get_receipt_url() {
1878
+
1879
+        // Retrieve the checkout url.
1880 1880
         $receipt_url = wpinv_get_success_page_uri();
1881 1881
 
1882
-		// Maybe force ssl.
1882
+        // Maybe force ssl.
1883 1883
         if ( is_ssl() ) {
1884 1884
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1885 1885
         }
1886 1886
 
1887
-		// Add the invoice key.
1888
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1887
+        // Add the invoice key.
1888
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1889 1889
 
1890 1890
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1891
-	}
1891
+    }
1892 1892
 	
1893
-	/**
1894
-	 * Retrieves the default status.
1895
-	 *
1896
-	 * @since 1.0.19
1897
-	 * @return string
1898
-	 */
1899
-	public function get_default_status() {
1900
-
1901
-		$type   = $this->get_type();
1902
-		$status = "wpi-$type-pending";
1903
-		return str_replace( '-invoice', '', $status );
1904
-
1905
-	}
1906
-
1907
-    /**
1908
-	 * Magic method for accessing invoice properties.
1909
-	 *
1910
-	 * @since 1.0.15
1911
-	 * @access public
1912
-	 *
1913
-	 * @param string $key Discount data to retrieve
1914
-	 * @param  string $context View or edit context.
1915
-	 * @return mixed Value of the given invoice property (if set).
1916
-	 */
1917
-	public function get( $key, $context = 'view' ) {
1893
+    /**
1894
+     * Retrieves the default status.
1895
+     *
1896
+     * @since 1.0.19
1897
+     * @return string
1898
+     */
1899
+    public function get_default_status() {
1900
+
1901
+        $type   = $this->get_type();
1902
+        $status = "wpi-$type-pending";
1903
+        return str_replace( '-invoice', '', $status );
1904
+
1905
+    }
1906
+
1907
+    /**
1908
+     * Magic method for accessing invoice properties.
1909
+     *
1910
+     * @since 1.0.15
1911
+     * @access public
1912
+     *
1913
+     * @param string $key Discount data to retrieve
1914
+     * @param  string $context View or edit context.
1915
+     * @return mixed Value of the given invoice property (if set).
1916
+     */
1917
+    public function get( $key, $context = 'view' ) {
1918 1918
         return $this->get_prop( $key, $context );
1919
-	}
1919
+    }
1920 1920
 
1921 1921
     /*
1922 1922
 	|--------------------------------------------------------------------------
@@ -1929,130 +1929,130 @@  discard block
 block discarded – undo
1929 1929
     */
1930 1930
 
1931 1931
     /**
1932
-	 * Magic method for setting invoice properties.
1933
-	 *
1934
-	 * @since 1.0.19
1935
-	 * @access public
1936
-	 *
1937
-	 * @param string $key Discount data to retrieve
1938
-	 * @param  mixed $value new value.
1939
-	 * @return mixed Value of the given invoice property (if set).
1940
-	 */
1941
-	public function set( $key, $value ) {
1932
+     * Magic method for setting invoice properties.
1933
+     *
1934
+     * @since 1.0.19
1935
+     * @access public
1936
+     *
1937
+     * @param string $key Discount data to retrieve
1938
+     * @param  mixed $value new value.
1939
+     * @return mixed Value of the given invoice property (if set).
1940
+     */
1941
+    public function set( $key, $value ) {
1942 1942
 
1943 1943
         $setter = "set_$key";
1944 1944
         if ( is_callable( array( $this, $setter ) ) ) {
1945 1945
             $this->{$setter}( $value );
1946 1946
         }
1947 1947
 
1948
-	}
1948
+    }
1949 1949
 
1950
-	/**
1951
-	 * Sets item status.
1952
-	 *
1953
-	 * @since 1.0.19
1954
-	 * @param string $new_status    New status.
1955
-	 * @param string $note          Optional note to add.
1956
-	 * @param bool   $manual_update Is this a manual status change?.
1957
-	 * @return array details of change.
1958
-	 */
1959
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1960
-		$old_status = $this->get_status();
1950
+    /**
1951
+     * Sets item status.
1952
+     *
1953
+     * @since 1.0.19
1954
+     * @param string $new_status    New status.
1955
+     * @param string $note          Optional note to add.
1956
+     * @param bool   $manual_update Is this a manual status change?.
1957
+     * @return array details of change.
1958
+     */
1959
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1960
+        $old_status = $this->get_status();
1961 1961
 
1962
-		$statuses = $this->get_all_statuses();
1962
+        $statuses = $this->get_all_statuses();
1963 1963
 
1964
-		if ( isset( $statuses[ 'draft' ] ) ) {
1965
-			unset( $statuses[ 'draft' ] );
1966
-		}
1964
+        if ( isset( $statuses[ 'draft' ] ) ) {
1965
+            unset( $statuses[ 'draft' ] );
1966
+        }
1967 1967
 
1968
-		$this->set_prop( 'status', $new_status );
1968
+        $this->set_prop( 'status', $new_status );
1969 1969
 
1970
-		// If setting the status, ensure it's set to a valid status.
1971
-		if ( true === $this->object_read ) {
1970
+        // If setting the status, ensure it's set to a valid status.
1971
+        if ( true === $this->object_read ) {
1972 1972
 
1973
-			// Only allow valid new status.
1974
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1975
-				$new_status = $this->get_default_status();
1976
-			}
1973
+            // Only allow valid new status.
1974
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1975
+                $new_status = $this->get_default_status();
1976
+            }
1977 1977
 
1978
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1979
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1980
-				$old_status = $this->get_default_status();
1981
-			}
1978
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1979
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1980
+                $old_status = $this->get_default_status();
1981
+            }
1982 1982
 
1983
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1984
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1985
-				$old_status = 'wpi-pending';
1986
-			}
1983
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1984
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1985
+                $old_status = 'wpi-pending';
1986
+            }
1987 1987
 
1988
-			if ( $old_status !== $new_status ) {
1989
-				$this->status_transition = array(
1990
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1991
-					'to'     => $new_status,
1992
-					'note'   => $note,
1993
-					'manual' => (bool) $manual_update,
1994
-				);
1988
+            if ( $old_status !== $new_status ) {
1989
+                $this->status_transition = array(
1990
+                    'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1991
+                    'to'     => $new_status,
1992
+                    'note'   => $note,
1993
+                    'manual' => (bool) $manual_update,
1994
+                );
1995 1995
 
1996
-				if ( $manual_update ) {
1997
-					do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1998
-				}
1996
+                if ( $manual_update ) {
1997
+                    do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1998
+                }
1999 1999
 
2000
-				$this->maybe_set_date_paid();
2000
+                $this->maybe_set_date_paid();
2001 2001
 
2002
-			}
2002
+            }
2003 2003
 
2004
-		}
2004
+        }
2005 2005
 
2006
-		return array(
2007
-			'from' => $old_status,
2008
-			'to'   => $new_status,
2009
-		);
2010
-	}
2006
+        return array(
2007
+            'from' => $old_status,
2008
+            'to'   => $new_status,
2009
+        );
2010
+    }
2011 2011
 
2012
-	/**
2013
-	 * Maybe set date paid.
2014
-	 *
2015
-	 * Sets the date paid variable when transitioning to the payment complete
2016
-	 * order status.
2017
-	 *
2018
-	 * @since 1.0.19
2019
-	 */
2020
-	public function maybe_set_date_paid() {
2012
+    /**
2013
+     * Maybe set date paid.
2014
+     *
2015
+     * Sets the date paid variable when transitioning to the payment complete
2016
+     * order status.
2017
+     *
2018
+     * @since 1.0.19
2019
+     */
2020
+    public function maybe_set_date_paid() {
2021 2021
 
2022
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2023
-			$this->set_date_completed( current_time( 'mysql' ) );
2024
-		}
2025
-	}
2022
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2023
+            $this->set_date_completed( current_time( 'mysql' ) );
2024
+        }
2025
+    }
2026 2026
 
2027 2027
     /**
2028
-	 * Set parent invoice ID.
2029
-	 *
2030
-	 * @since 1.0.19
2031
-	 */
2032
-	public function set_parent_id( $value ) {
2033
-		if ( $value && ( $value === $this->get_id() ) ) {
2034
-			return;
2035
-		}
2036
-		$this->set_prop( 'parent_id', absint( $value ) );
2028
+     * Set parent invoice ID.
2029
+     *
2030
+     * @since 1.0.19
2031
+     */
2032
+    public function set_parent_id( $value ) {
2033
+        if ( $value && ( $value === $this->get_id() ) ) {
2034
+            return;
2035
+        }
2036
+        $this->set_prop( 'parent_id', absint( $value ) );
2037 2037
     }
2038 2038
 
2039 2039
     /**
2040
-	 * Set plugin version when the invoice was created.
2041
-	 *
2042
-	 * @since 1.0.19
2043
-	 */
2044
-	public function set_version( $value ) {
2045
-		$this->set_prop( 'version', $value );
2040
+     * Set plugin version when the invoice was created.
2041
+     *
2042
+     * @since 1.0.19
2043
+     */
2044
+    public function set_version( $value ) {
2045
+        $this->set_prop( 'version', $value );
2046 2046
     }
2047
-
2048
-    /**
2049
-	 * Set date when the invoice was created.
2050
-	 *
2051
-	 * @since 1.0.19
2052
-	 * @param string $value Value to set.
2047
+
2048
+    /**
2049
+     * Set date when the invoice was created.
2050
+     *
2051
+     * @since 1.0.19
2052
+     * @param string $value Value to set.
2053 2053
      * @return bool Whether or not the date was set.
2054
-	 */
2055
-	public function set_date_created( $value ) {
2054
+     */
2055
+    public function set_date_created( $value ) {
2056 2056
         $date = strtotime( $value );
2057 2057
 
2058 2058
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2060,19 +2060,19 @@  discard block
 block discarded – undo
2060 2060
             return true;
2061 2061
         }
2062 2062
 
2063
-		$this->set_prop( 'date_created', '' );
2064
-		return false;
2063
+        $this->set_prop( 'date_created', '' );
2064
+        return false;
2065 2065
 
2066 2066
     }
2067 2067
 
2068 2068
     /**
2069
-	 * Set date invoice due date.
2070
-	 *
2071
-	 * @since 1.0.19
2072
-	 * @param string $value Value to set.
2069
+     * Set date invoice due date.
2070
+     *
2071
+     * @since 1.0.19
2072
+     * @param string $value Value to set.
2073 2073
      * @return bool Whether or not the date was set.
2074
-	 */
2075
-	public function set_due_date( $value ) {
2074
+     */
2075
+    public function set_due_date( $value ) {
2076 2076
         $date = strtotime( $value );
2077 2077
 
2078 2078
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2080,29 +2080,29 @@  discard block
 block discarded – undo
2080 2080
             return true;
2081 2081
         }
2082 2082
 
2083
-		$this->set_prop( 'due_date', '' );
2083
+        $this->set_prop( 'due_date', '' );
2084 2084
         return false;
2085 2085
 
2086 2086
     }
2087 2087
 
2088 2088
     /**
2089
-	 * Alias of self::set_due_date().
2090
-	 *
2091
-	 * @since 1.0.19
2092
-	 * @param  string $value New name.
2093
-	 */
2094
-	public function set_date_due( $value ) {
2095
-		$this->set_due_date( $value );
2089
+     * Alias of self::set_due_date().
2090
+     *
2091
+     * @since 1.0.19
2092
+     * @param  string $value New name.
2093
+     */
2094
+    public function set_date_due( $value ) {
2095
+        $this->set_due_date( $value );
2096 2096
     }
2097 2097
 
2098 2098
     /**
2099
-	 * Set date invoice was completed.
2100
-	 *
2101
-	 * @since 1.0.19
2102
-	 * @param string $value Value to set.
2099
+     * Set date invoice was completed.
2100
+     *
2101
+     * @since 1.0.19
2102
+     * @param string $value Value to set.
2103 2103
      * @return bool Whether or not the date was set.
2104
-	 */
2105
-	public function set_completed_date( $value ) {
2104
+     */
2105
+    public function set_completed_date( $value ) {
2106 2106
         $date = strtotime( $value );
2107 2107
 
2108 2108
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2110,29 +2110,29 @@  discard block
 block discarded – undo
2110 2110
             return true;
2111 2111
         }
2112 2112
 
2113
-		$this->set_prop( 'completed_date', '' );
2113
+        $this->set_prop( 'completed_date', '' );
2114 2114
         return false;
2115 2115
 
2116 2116
     }
2117 2117
 
2118 2118
     /**
2119
-	 * Alias of self::set_completed_date().
2120
-	 *
2121
-	 * @since 1.0.19
2122
-	 * @param  string $value New name.
2123
-	 */
2124
-	public function set_date_completed( $value ) {
2125
-		$this->set_completed_date( $value );
2119
+     * Alias of self::set_completed_date().
2120
+     *
2121
+     * @since 1.0.19
2122
+     * @param  string $value New name.
2123
+     */
2124
+    public function set_date_completed( $value ) {
2125
+        $this->set_completed_date( $value );
2126 2126
     }
2127 2127
 
2128 2128
     /**
2129
-	 * Set date when the invoice was last modified.
2130
-	 *
2131
-	 * @since 1.0.19
2132
-	 * @param string $value Value to set.
2129
+     * Set date when the invoice was last modified.
2130
+     *
2131
+     * @since 1.0.19
2132
+     * @param string $value Value to set.
2133 2133
      * @return bool Whether or not the date was set.
2134
-	 */
2135
-	public function set_date_modified( $value ) {
2134
+     */
2135
+    public function set_date_modified( $value ) {
2136 2136
         $date = strtotime( $value );
2137 2137
 
2138 2138
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2140,798 +2140,798 @@  discard block
 block discarded – undo
2140 2140
             return true;
2141 2141
         }
2142 2142
 
2143
-		$this->set_prop( 'date_modified', '' );
2143
+        $this->set_prop( 'date_modified', '' );
2144 2144
         return false;
2145 2145
 
2146 2146
     }
2147 2147
 
2148 2148
     /**
2149
-	 * Set the invoice number.
2150
-	 *
2151
-	 * @since 1.0.19
2152
-	 * @param  string $value New number.
2153
-	 */
2154
-	public function set_number( $value ) {
2149
+     * Set the invoice number.
2150
+     *
2151
+     * @since 1.0.19
2152
+     * @param  string $value New number.
2153
+     */
2154
+    public function set_number( $value ) {
2155 2155
         $number = sanitize_text_field( $value );
2156
-		$this->set_prop( 'number', $number );
2156
+        $this->set_prop( 'number', $number );
2157 2157
     }
2158 2158
 
2159 2159
     /**
2160
-	 * Set the invoice type.
2161
-	 *
2162
-	 * @since 1.0.19
2163
-	 * @param  string $value Type.
2164
-	 */
2165
-	public function set_type( $value ) {
2160
+     * Set the invoice type.
2161
+     *
2162
+     * @since 1.0.19
2163
+     * @param  string $value Type.
2164
+     */
2165
+    public function set_type( $value ) {
2166 2166
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2167
-		$this->set_prop( 'type', $type );
2168
-	}
2167
+        $this->set_prop( 'type', $type );
2168
+    }
2169 2169
 
2170 2170
     /**
2171
-	 * Set the invoice post type.
2172
-	 *
2173
-	 * @since 1.0.19
2174
-	 * @param  string $value Post type.
2175
-	 */
2176
-	public function set_post_type( $value ) {
2171
+     * Set the invoice post type.
2172
+     *
2173
+     * @since 1.0.19
2174
+     * @param  string $value Post type.
2175
+     */
2176
+    public function set_post_type( $value ) {
2177 2177
         if ( getpaid_is_invoice_post_type( $value ) ) {
2178
-			$this->set_type( $value );
2178
+            $this->set_type( $value );
2179 2179
             $this->set_prop( 'post_type', $value );
2180 2180
         }
2181 2181
     }
2182 2182
 
2183 2183
     /**
2184
-	 * Set the invoice key.
2185
-	 *
2186
-	 * @since 1.0.19
2187
-	 * @param  string $value New key.
2188
-	 */
2189
-	public function set_key( $value ) {
2184
+     * Set the invoice key.
2185
+     *
2186
+     * @since 1.0.19
2187
+     * @param  string $value New key.
2188
+     */
2189
+    public function set_key( $value ) {
2190 2190
         $key = sanitize_text_field( $value );
2191
-		$this->set_prop( 'key', $key );
2191
+        $this->set_prop( 'key', $key );
2192 2192
     }
2193 2193
 
2194 2194
     /**
2195
-	 * Set the invoice mode.
2196
-	 *
2197
-	 * @since 1.0.19
2198
-	 * @param  string $value mode.
2199
-	 */
2200
-	public function set_mode( $value ) {
2195
+     * Set the invoice mode.
2196
+     *
2197
+     * @since 1.0.19
2198
+     * @param  string $value mode.
2199
+     */
2200
+    public function set_mode( $value ) {
2201 2201
         if ( in_array( $value, array( 'live', 'test' ) ) ) {
2202 2202
             $this->set_prop( 'mode', $value );
2203 2203
         }
2204 2204
     }
2205 2205
 
2206 2206
     /**
2207
-	 * Set the invoice path.
2208
-	 *
2209
-	 * @since 1.0.19
2210
-	 * @param  string $value path.
2211
-	 */
2212
-	public function set_path( $value ) {
2207
+     * Set the invoice path.
2208
+     *
2209
+     * @since 1.0.19
2210
+     * @param  string $value path.
2211
+     */
2212
+    public function set_path( $value ) {
2213 2213
         $this->set_prop( 'path', $value );
2214 2214
     }
2215 2215
 
2216 2216
     /**
2217
-	 * Set the invoice name.
2218
-	 *
2219
-	 * @since 1.0.19
2220
-	 * @param  string $value New name.
2221
-	 */
2222
-	public function set_name( $value ) {
2217
+     * Set the invoice name.
2218
+     *
2219
+     * @since 1.0.19
2220
+     * @param  string $value New name.
2221
+     */
2222
+    public function set_name( $value ) {
2223 2223
         $name = sanitize_text_field( $value );
2224
-		$this->set_prop( 'name', $name );
2224
+        $this->set_prop( 'name', $name );
2225 2225
     }
2226 2226
 
2227 2227
     /**
2228
-	 * Alias of self::set_name().
2229
-	 *
2230
-	 * @since 1.0.19
2231
-	 * @param  string $value New name.
2232
-	 */
2233
-	public function set_title( $value ) {
2234
-		$this->set_name( $value );
2228
+     * Alias of self::set_name().
2229
+     *
2230
+     * @since 1.0.19
2231
+     * @param  string $value New name.
2232
+     */
2233
+    public function set_title( $value ) {
2234
+        $this->set_name( $value );
2235 2235
     }
2236 2236
 
2237 2237
     /**
2238
-	 * Set the invoice description.
2239
-	 *
2240
-	 * @since 1.0.19
2241
-	 * @param  string $value New description.
2242
-	 */
2243
-	public function set_description( $value ) {
2238
+     * Set the invoice description.
2239
+     *
2240
+     * @since 1.0.19
2241
+     * @param  string $value New description.
2242
+     */
2243
+    public function set_description( $value ) {
2244 2244
         $description = wp_kses_post( $value );
2245
-		$this->set_prop( 'description', $description );
2245
+        $this->set_prop( 'description', $description );
2246
+    }
2247
+
2248
+    /**
2249
+     * Alias of self::set_description().
2250
+     *
2251
+     * @since 1.0.19
2252
+     * @param  string $value New description.
2253
+     */
2254
+    public function set_excerpt( $value ) {
2255
+        $this->set_description( $value );
2256
+    }
2257
+
2258
+    /**
2259
+     * Alias of self::set_description().
2260
+     *
2261
+     * @since 1.0.19
2262
+     * @param  string $value New description.
2263
+     */
2264
+    public function set_summary( $value ) {
2265
+        $this->set_description( $value );
2266
+    }
2267
+
2268
+    /**
2269
+     * Set the receiver of the invoice.
2270
+     *
2271
+     * @since 1.0.19
2272
+     * @param  int $value New author.
2273
+     */
2274
+    public function set_author( $value ) {
2275
+        $user = get_user_by( 'id', (int) $value );
2276
+
2277
+        if ( $user && $user->ID ) {
2278
+            $this->set_prop( 'author', $user->ID );
2279
+            $this->set_prop( 'email', $user->user_email );
2280
+        }
2281
+
2282
+    }
2283
+
2284
+    /**
2285
+     * Alias of self::set_author().
2286
+     *
2287
+     * @since 1.0.19
2288
+     * @param  int $value New user id.
2289
+     */
2290
+    public function set_user_id( $value ) {
2291
+        $this->set_author( $value );
2292
+    }
2293
+
2294
+    /**
2295
+     * Alias of self::set_author().
2296
+     *
2297
+     * @since 1.0.19
2298
+     * @param  int $value New user id.
2299
+     */
2300
+    public function set_customer_id( $value ) {
2301
+        $this->set_author( $value );
2302
+    }
2303
+
2304
+    /**
2305
+     * Set the customer's ip.
2306
+     *
2307
+     * @since 1.0.19
2308
+     * @param  string $value ip address.
2309
+     */
2310
+    public function set_ip( $value ) {
2311
+        $this->set_prop( 'ip', $value );
2312
+    }
2313
+
2314
+    /**
2315
+     * Alias of self::set_ip().
2316
+     *
2317
+     * @since 1.0.19
2318
+     * @param  string $value ip address.
2319
+     */
2320
+    public function set_user_ip( $value ) {
2321
+        $this->set_ip( $value );
2322
+    }
2323
+
2324
+    /**
2325
+     * Set the customer's first name.
2326
+     *
2327
+     * @since 1.0.19
2328
+     * @param  string $value first name.
2329
+     */
2330
+    public function set_first_name( $value ) {
2331
+        $this->set_prop( 'first_name', $value );
2332
+    }
2333
+
2334
+    /**
2335
+     * Alias of self::set_first_name().
2336
+     *
2337
+     * @since 1.0.19
2338
+     * @param  string $value first name.
2339
+     */
2340
+    public function set_user_first_name( $value ) {
2341
+        $this->set_first_name( $value );
2342
+    }
2343
+
2344
+    /**
2345
+     * Alias of self::set_first_name().
2346
+     *
2347
+     * @since 1.0.19
2348
+     * @param  string $value first name.
2349
+     */
2350
+    public function set_customer_first_name( $value ) {
2351
+        $this->set_first_name( $value );
2352
+    }
2353
+
2354
+    /**
2355
+     * Set the customer's last name.
2356
+     *
2357
+     * @since 1.0.19
2358
+     * @param  string $value last name.
2359
+     */
2360
+    public function set_last_name( $value ) {
2361
+        $this->set_prop( 'last_name', $value );
2246 2362
     }
2247 2363
 
2248 2364
     /**
2249
-	 * Alias of self::set_description().
2250
-	 *
2251
-	 * @since 1.0.19
2252
-	 * @param  string $value New description.
2253
-	 */
2254
-	public function set_excerpt( $value ) {
2255
-		$this->set_description( $value );
2365
+     * Alias of self::set_last_name().
2366
+     *
2367
+     * @since 1.0.19
2368
+     * @param  string $value last name.
2369
+     */
2370
+    public function set_user_last_name( $value ) {
2371
+        $this->set_last_name( $value );
2372
+    }
2373
+
2374
+    /**
2375
+     * Alias of self::set_last_name().
2376
+     *
2377
+     * @since 1.0.19
2378
+     * @param  string $value last name.
2379
+     */
2380
+    public function set_customer_last_name( $value ) {
2381
+        $this->set_last_name( $value );
2382
+    }
2383
+
2384
+    /**
2385
+     * Set the customer's phone number.
2386
+     *
2387
+     * @since 1.0.19
2388
+     * @param  string $value phone.
2389
+     */
2390
+    public function set_phone( $value ) {
2391
+        $this->set_prop( 'phone', $value );
2256 2392
     }
2257 2393
 
2258 2394
     /**
2259
-	 * Alias of self::set_description().
2260
-	 *
2261
-	 * @since 1.0.19
2262
-	 * @param  string $value New description.
2263
-	 */
2264
-	public function set_summary( $value ) {
2265
-		$this->set_description( $value );
2395
+     * Alias of self::set_phone().
2396
+     *
2397
+     * @since 1.0.19
2398
+     * @param  string $value phone.
2399
+     */
2400
+    public function set_user_phone( $value ) {
2401
+        $this->set_phone( $value );
2266 2402
     }
2267 2403
 
2268 2404
     /**
2269
-	 * Set the receiver of the invoice.
2270
-	 *
2271
-	 * @since 1.0.19
2272
-	 * @param  int $value New author.
2273
-	 */
2274
-	public function set_author( $value ) {
2275
-		$user = get_user_by( 'id', (int) $value );
2405
+     * Alias of self::set_phone().
2406
+     *
2407
+     * @since 1.0.19
2408
+     * @param  string $value phone.
2409
+     */
2410
+    public function set_customer_phone( $value ) {
2411
+        $this->set_phone( $value );
2412
+    }
2276 2413
 
2277
-		if ( $user && $user->ID ) {
2278
-			$this->set_prop( 'author', $user->ID );
2279
-			$this->set_prop( 'email', $user->user_email );
2280
-		}
2414
+    /**
2415
+     * Alias of self::set_phone().
2416
+     *
2417
+     * @since 1.0.19
2418
+     * @param  string $value phone.
2419
+     */
2420
+    public function set_phone_number( $value ) {
2421
+        $this->set_phone( $value );
2422
+    }
2281 2423
 
2424
+    /**
2425
+     * Set the customer's email address.
2426
+     *
2427
+     * @since 1.0.19
2428
+     * @param  string $value email address.
2429
+     */
2430
+    public function set_email( $value ) {
2431
+        $this->set_prop( 'email', $value );
2282 2432
     }
2283 2433
 
2284 2434
     /**
2285
-	 * Alias of self::set_author().
2286
-	 *
2287
-	 * @since 1.0.19
2288
-	 * @param  int $value New user id.
2289
-	 */
2290
-	public function set_user_id( $value ) {
2291
-		$this->set_author( $value );
2435
+     * Alias of self::set_email().
2436
+     *
2437
+     * @since 1.0.19
2438
+     * @param  string $value email address.
2439
+     */
2440
+    public function set_user_email( $value ) {
2441
+        $this->set_email( $value );
2292 2442
     }
2293 2443
 
2294 2444
     /**
2295
-	 * Alias of self::set_author().
2296
-	 *
2297
-	 * @since 1.0.19
2298
-	 * @param  int $value New user id.
2299
-	 */
2300
-	public function set_customer_id( $value ) {
2301
-		$this->set_author( $value );
2445
+     * Alias of self::set_email().
2446
+     *
2447
+     * @since 1.0.19
2448
+     * @param  string $value email address.
2449
+     */
2450
+    public function set_email_address( $value ) {
2451
+        $this->set_email( $value );
2302 2452
     }
2303 2453
 
2304 2454
     /**
2305
-	 * Set the customer's ip.
2306
-	 *
2307
-	 * @since 1.0.19
2308
-	 * @param  string $value ip address.
2309
-	 */
2310
-	public function set_ip( $value ) {
2311
-		$this->set_prop( 'ip', $value );
2455
+     * Alias of self::set_email().
2456
+     *
2457
+     * @since 1.0.19
2458
+     * @param  string $value email address.
2459
+     */
2460
+    public function set_customer_email( $value ) {
2461
+        $this->set_email( $value );
2312 2462
     }
2313 2463
 
2314 2464
     /**
2315
-	 * Alias of self::set_ip().
2316
-	 *
2317
-	 * @since 1.0.19
2318
-	 * @param  string $value ip address.
2319
-	 */
2320
-	public function set_user_ip( $value ) {
2321
-		$this->set_ip( $value );
2465
+     * Set the customer's country.
2466
+     *
2467
+     * @since 1.0.19
2468
+     * @param  string $value country.
2469
+     */
2470
+    public function set_country( $value ) {
2471
+        $this->set_prop( 'country', $value );
2322 2472
     }
2323 2473
 
2324 2474
     /**
2325
-	 * Set the customer's first name.
2326
-	 *
2327
-	 * @since 1.0.19
2328
-	 * @param  string $value first name.
2329
-	 */
2330
-	public function set_first_name( $value ) {
2331
-		$this->set_prop( 'first_name', $value );
2475
+     * Alias of self::set_country().
2476
+     *
2477
+     * @since 1.0.19
2478
+     * @param  string $value country.
2479
+     */
2480
+    public function set_user_country( $value ) {
2481
+        $this->set_country( $value );
2332 2482
     }
2333 2483
 
2334 2484
     /**
2335
-	 * Alias of self::set_first_name().
2336
-	 *
2337
-	 * @since 1.0.19
2338
-	 * @param  string $value first name.
2339
-	 */
2340
-	public function set_user_first_name( $value ) {
2341
-		$this->set_first_name( $value );
2485
+     * Alias of self::set_country().
2486
+     *
2487
+     * @since 1.0.19
2488
+     * @param  string $value country.
2489
+     */
2490
+    public function set_customer_country( $value ) {
2491
+        $this->set_country( $value );
2342 2492
     }
2343 2493
 
2344 2494
     /**
2345
-	 * Alias of self::set_first_name().
2346
-	 *
2347
-	 * @since 1.0.19
2348
-	 * @param  string $value first name.
2349
-	 */
2350
-	public function set_customer_first_name( $value ) {
2351
-		$this->set_first_name( $value );
2495
+     * Set the customer's state.
2496
+     *
2497
+     * @since 1.0.19
2498
+     * @param  string $value state.
2499
+     */
2500
+    public function set_state( $value ) {
2501
+        $this->set_prop( 'state', $value );
2352 2502
     }
2353 2503
 
2354 2504
     /**
2355
-	 * Set the customer's last name.
2356
-	 *
2357
-	 * @since 1.0.19
2358
-	 * @param  string $value last name.
2359
-	 */
2360
-	public function set_last_name( $value ) {
2361
-		$this->set_prop( 'last_name', $value );
2505
+     * Alias of self::set_state().
2506
+     *
2507
+     * @since 1.0.19
2508
+     * @param  string $value state.
2509
+     */
2510
+    public function set_user_state( $value ) {
2511
+        $this->set_state( $value );
2362 2512
     }
2363 2513
 
2364 2514
     /**
2365
-	 * Alias of self::set_last_name().
2366
-	 *
2367
-	 * @since 1.0.19
2368
-	 * @param  string $value last name.
2369
-	 */
2370
-	public function set_user_last_name( $value ) {
2371
-		$this->set_last_name( $value );
2515
+     * Alias of self::set_state().
2516
+     *
2517
+     * @since 1.0.19
2518
+     * @param  string $value state.
2519
+     */
2520
+    public function set_customer_state( $value ) {
2521
+        $this->set_state( $value );
2372 2522
     }
2373 2523
 
2374 2524
     /**
2375
-	 * Alias of self::set_last_name().
2376
-	 *
2377
-	 * @since 1.0.19
2378
-	 * @param  string $value last name.
2379
-	 */
2380
-	public function set_customer_last_name( $value ) {
2381
-		$this->set_last_name( $value );
2525
+     * Set the customer's city.
2526
+     *
2527
+     * @since 1.0.19
2528
+     * @param  string $value city.
2529
+     */
2530
+    public function set_city( $value ) {
2531
+        $this->set_prop( 'city', $value );
2382 2532
     }
2383 2533
 
2384 2534
     /**
2385
-	 * Set the customer's phone number.
2386
-	 *
2387
-	 * @since 1.0.19
2388
-	 * @param  string $value phone.
2389
-	 */
2390
-	public function set_phone( $value ) {
2391
-		$this->set_prop( 'phone', $value );
2535
+     * Alias of self::set_city().
2536
+     *
2537
+     * @since 1.0.19
2538
+     * @param  string $value city.
2539
+     */
2540
+    public function set_user_city( $value ) {
2541
+        $this->set_city( $value );
2392 2542
     }
2393 2543
 
2394 2544
     /**
2395
-	 * Alias of self::set_phone().
2396
-	 *
2397
-	 * @since 1.0.19
2398
-	 * @param  string $value phone.
2399
-	 */
2400
-	public function set_user_phone( $value ) {
2401
-		$this->set_phone( $value );
2545
+     * Alias of self::set_city().
2546
+     *
2547
+     * @since 1.0.19
2548
+     * @param  string $value city.
2549
+     */
2550
+    public function set_customer_city( $value ) {
2551
+        $this->set_city( $value );
2402 2552
     }
2403 2553
 
2404 2554
     /**
2405
-	 * Alias of self::set_phone().
2406
-	 *
2407
-	 * @since 1.0.19
2408
-	 * @param  string $value phone.
2409
-	 */
2410
-	public function set_customer_phone( $value ) {
2411
-		$this->set_phone( $value );
2555
+     * Set the customer's zip code.
2556
+     *
2557
+     * @since 1.0.19
2558
+     * @param  string $value zip.
2559
+     */
2560
+    public function set_zip( $value ) {
2561
+        $this->set_prop( 'zip', $value );
2412 2562
     }
2413 2563
 
2414 2564
     /**
2415
-	 * Alias of self::set_phone().
2416
-	 *
2417
-	 * @since 1.0.19
2418
-	 * @param  string $value phone.
2419
-	 */
2420
-	public function set_phone_number( $value ) {
2421
-		$this->set_phone( $value );
2565
+     * Alias of self::set_zip().
2566
+     *
2567
+     * @since 1.0.19
2568
+     * @param  string $value zip.
2569
+     */
2570
+    public function set_user_zip( $value ) {
2571
+        $this->set_zip( $value );
2422 2572
     }
2423 2573
 
2424 2574
     /**
2425
-	 * Set the customer's email address.
2426
-	 *
2427
-	 * @since 1.0.19
2428
-	 * @param  string $value email address.
2429
-	 */
2430
-	public function set_email( $value ) {
2431
-		$this->set_prop( 'email', $value );
2575
+     * Alias of self::set_zip().
2576
+     *
2577
+     * @since 1.0.19
2578
+     * @param  string $value zip.
2579
+     */
2580
+    public function set_customer_zip( $value ) {
2581
+        $this->set_zip( $value );
2432 2582
     }
2433 2583
 
2434 2584
     /**
2435
-	 * Alias of self::set_email().
2436
-	 *
2437
-	 * @since 1.0.19
2438
-	 * @param  string $value email address.
2439
-	 */
2440
-	public function set_user_email( $value ) {
2441
-		$this->set_email( $value );
2585
+     * Set the customer's company.
2586
+     *
2587
+     * @since 1.0.19
2588
+     * @param  string $value company.
2589
+     */
2590
+    public function set_company( $value ) {
2591
+        $this->set_prop( 'company', $value );
2442 2592
     }
2443 2593
 
2444 2594
     /**
2445
-	 * Alias of self::set_email().
2446
-	 *
2447
-	 * @since 1.0.19
2448
-	 * @param  string $value email address.
2449
-	 */
2450
-	public function set_email_address( $value ) {
2451
-		$this->set_email( $value );
2595
+     * Alias of self::set_company().
2596
+     *
2597
+     * @since 1.0.19
2598
+     * @param  string $value company.
2599
+     */
2600
+    public function set_user_company( $value ) {
2601
+        $this->set_company( $value );
2452 2602
     }
2453 2603
 
2454 2604
     /**
2455
-	 * Alias of self::set_email().
2456
-	 *
2457
-	 * @since 1.0.19
2458
-	 * @param  string $value email address.
2459
-	 */
2460
-	public function set_customer_email( $value ) {
2461
-		$this->set_email( $value );
2605
+     * Alias of self::set_company().
2606
+     *
2607
+     * @since 1.0.19
2608
+     * @param  string $value company.
2609
+     */
2610
+    public function set_customer_company( $value ) {
2611
+        $this->set_company( $value );
2462 2612
     }
2463 2613
 
2464 2614
     /**
2465
-	 * Set the customer's country.
2466
-	 *
2467
-	 * @since 1.0.19
2468
-	 * @param  string $value country.
2469
-	 */
2470
-	public function set_country( $value ) {
2471
-		$this->set_prop( 'country', $value );
2615
+     * Set the customer's company id.
2616
+     *
2617
+     * @since 1.0.19
2618
+     * @param  string $value company id.
2619
+     */
2620
+    public function set_company_id( $value ) {
2621
+        $this->set_prop( 'company_id', $value );
2472 2622
     }
2473 2623
 
2474 2624
     /**
2475
-	 * Alias of self::set_country().
2476
-	 *
2477
-	 * @since 1.0.19
2478
-	 * @param  string $value country.
2479
-	 */
2480
-	public function set_user_country( $value ) {
2481
-		$this->set_country( $value );
2625
+     * Set the customer's var number.
2626
+     *
2627
+     * @since 1.0.19
2628
+     * @param  string $value var number.
2629
+     */
2630
+    public function set_vat_number( $value ) {
2631
+        $this->set_prop( 'vat_number', $value );
2482 2632
     }
2483 2633
 
2484 2634
     /**
2485
-	 * Alias of self::set_country().
2486
-	 *
2487
-	 * @since 1.0.19
2488
-	 * @param  string $value country.
2489
-	 */
2490
-	public function set_customer_country( $value ) {
2491
-		$this->set_country( $value );
2635
+     * Alias of self::set_vat_number().
2636
+     *
2637
+     * @since 1.0.19
2638
+     * @param  string $value var number.
2639
+     */
2640
+    public function set_user_vat_number( $value ) {
2641
+        $this->set_vat_number( $value );
2492 2642
     }
2493 2643
 
2494 2644
     /**
2495
-	 * Set the customer's state.
2496
-	 *
2497
-	 * @since 1.0.19
2498
-	 * @param  string $value state.
2499
-	 */
2500
-	public function set_state( $value ) {
2501
-		$this->set_prop( 'state', $value );
2645
+     * Alias of self::set_vat_number().
2646
+     *
2647
+     * @since 1.0.19
2648
+     * @param  string $value var number.
2649
+     */
2650
+    public function set_customer_vat_number( $value ) {
2651
+        $this->set_vat_number( $value );
2502 2652
     }
2503 2653
 
2504 2654
     /**
2505
-	 * Alias of self::set_state().
2506
-	 *
2507
-	 * @since 1.0.19
2508
-	 * @param  string $value state.
2509
-	 */
2510
-	public function set_user_state( $value ) {
2511
-		$this->set_state( $value );
2655
+     * Set the customer's vat rate.
2656
+     *
2657
+     * @since 1.0.19
2658
+     * @param  string $value var rate.
2659
+     */
2660
+    public function set_vat_rate( $value ) {
2661
+        $this->set_prop( 'vat_rate', $value );
2512 2662
     }
2513 2663
 
2514 2664
     /**
2515
-	 * Alias of self::set_state().
2516
-	 *
2517
-	 * @since 1.0.19
2518
-	 * @param  string $value state.
2519
-	 */
2520
-	public function set_customer_state( $value ) {
2521
-		$this->set_state( $value );
2665
+     * Alias of self::set_vat_rate().
2666
+     *
2667
+     * @since 1.0.19
2668
+     * @param  string $value var number.
2669
+     */
2670
+    public function set_user_vat_rate( $value ) {
2671
+        $this->set_vat_rate( $value );
2522 2672
     }
2523 2673
 
2524 2674
     /**
2525
-	 * Set the customer's city.
2526
-	 *
2527
-	 * @since 1.0.19
2528
-	 * @param  string $value city.
2529
-	 */
2530
-	public function set_city( $value ) {
2531
-		$this->set_prop( 'city', $value );
2675
+     * Alias of self::set_vat_rate().
2676
+     *
2677
+     * @since 1.0.19
2678
+     * @param  string $value var number.
2679
+     */
2680
+    public function set_customer_vat_rate( $value ) {
2681
+        $this->set_vat_rate( $value );
2532 2682
     }
2533 2683
 
2534 2684
     /**
2535
-	 * Alias of self::set_city().
2536
-	 *
2537
-	 * @since 1.0.19
2538
-	 * @param  string $value city.
2539
-	 */
2540
-	public function set_user_city( $value ) {
2541
-		$this->set_city( $value );
2685
+     * Set the customer's address.
2686
+     *
2687
+     * @since 1.0.19
2688
+     * @param  string $value address.
2689
+     */
2690
+    public function set_address( $value ) {
2691
+        $this->set_prop( 'address', $value );
2542 2692
     }
2543 2693
 
2544 2694
     /**
2545
-	 * Alias of self::set_city().
2546
-	 *
2547
-	 * @since 1.0.19
2548
-	 * @param  string $value city.
2549
-	 */
2550
-	public function set_customer_city( $value ) {
2551
-		$this->set_city( $value );
2695
+     * Alias of self::set_address().
2696
+     *
2697
+     * @since 1.0.19
2698
+     * @param  string $value address.
2699
+     */
2700
+    public function set_user_address( $value ) {
2701
+        $this->set_address( $value );
2552 2702
     }
2553 2703
 
2554 2704
     /**
2555
-	 * Set the customer's zip code.
2556
-	 *
2557
-	 * @since 1.0.19
2558
-	 * @param  string $value zip.
2559
-	 */
2560
-	public function set_zip( $value ) {
2561
-		$this->set_prop( 'zip', $value );
2705
+     * Alias of self::set_address().
2706
+     *
2707
+     * @since 1.0.19
2708
+     * @param  string $value address.
2709
+     */
2710
+    public function set_customer_address( $value ) {
2711
+        $this->set_address( $value );
2562 2712
     }
2563 2713
 
2564 2714
     /**
2565
-	 * Alias of self::set_zip().
2566
-	 *
2567
-	 * @since 1.0.19
2568
-	 * @param  string $value zip.
2569
-	 */
2570
-	public function set_user_zip( $value ) {
2571
-		$this->set_zip( $value );
2715
+     * Set whether the customer has viewed the invoice or not.
2716
+     *
2717
+     * @since 1.0.19
2718
+     * @param  int|bool $value confirmed.
2719
+     */
2720
+    public function set_is_viewed( $value ) {
2721
+        $this->set_prop( 'is_viewed', $value );
2572 2722
     }
2573 2723
 
2574 2724
     /**
2575
-	 * Alias of self::set_zip().
2576
-	 *
2577
-	 * @since 1.0.19
2578
-	 * @param  string $value zip.
2579
-	 */
2580
-	public function set_customer_zip( $value ) {
2581
-		$this->set_zip( $value );
2725
+     * Set extra email recipients.
2726
+     *
2727
+     * @since 1.0.19
2728
+     * @param  string $value email recipients.
2729
+     */
2730
+    public function set_email_cc( $value ) {
2731
+        $this->set_prop( 'email_cc', $value );
2582 2732
     }
2583 2733
 
2584 2734
     /**
2585
-	 * Set the customer's company.
2586
-	 *
2587
-	 * @since 1.0.19
2588
-	 * @param  string $value company.
2589
-	 */
2590
-	public function set_company( $value ) {
2591
-		$this->set_prop( 'company', $value );
2735
+     * Set the invoice template.
2736
+     *
2737
+     * @since 1.0.19
2738
+     * @param  string $value template.
2739
+     */
2740
+    public function set_template( $value ) {
2741
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2742
+            $this->set_prop( 'template', $value );
2743
+        }
2592 2744
     }
2593 2745
 
2594 2746
     /**
2595
-	 * Alias of self::set_company().
2596
-	 *
2597
-	 * @since 1.0.19
2598
-	 * @param  string $value company.
2599
-	 */
2600
-	public function set_user_company( $value ) {
2601
-		$this->set_company( $value );
2747
+     * Set the invoice source.
2748
+     *
2749
+     * @since 1.0.19
2750
+     * @param  string $value source.
2751
+     * @deprecated
2752
+     */
2753
+    public function created_via( $value ) {
2754
+        $this->set_created_via( sanitize_text_field( $value ) );
2602 2755
     }
2603 2756
 
2604 2757
     /**
2605
-	 * Alias of self::set_company().
2606
-	 *
2607
-	 * @since 1.0.19
2608
-	 * @param  string $value company.
2609
-	 */
2610
-	public function set_customer_company( $value ) {
2611
-		$this->set_company( $value );
2758
+     * Set the invoice source.
2759
+     *
2760
+     * @since 1.0.19
2761
+     * @param  string $value source.
2762
+     */
2763
+    public function set_created_via( $value ) {
2764
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2612 2765
     }
2613 2766
 
2614
-	/**
2615
-	 * Set the customer's company id.
2616
-	 *
2617
-	 * @since 1.0.19
2618
-	 * @param  string $value company id.
2619
-	 */
2620
-	public function set_company_id( $value ) {
2621
-		$this->set_prop( 'company_id', $value );
2767
+    /**
2768
+     * Set the customer's address confirmed status.
2769
+     *
2770
+     * @since 1.0.19
2771
+     * @param  int|bool $value confirmed.
2772
+     */
2773
+    public function set_address_confirmed( $value ) {
2774
+        $this->set_prop( 'address_confirmed', $value );
2622 2775
     }
2623 2776
 
2624 2777
     /**
2625
-	 * Set the customer's var number.
2626
-	 *
2627
-	 * @since 1.0.19
2628
-	 * @param  string $value var number.
2629
-	 */
2630
-	public function set_vat_number( $value ) {
2631
-		$this->set_prop( 'vat_number', $value );
2778
+     * Alias of self::set_address_confirmed().
2779
+     *
2780
+     * @since 1.0.19
2781
+     * @param  int|bool $value confirmed.
2782
+     */
2783
+    public function set_user_address_confirmed( $value ) {
2784
+        $this->set_address_confirmed( $value );
2632 2785
     }
2633 2786
 
2634 2787
     /**
2635
-	 * Alias of self::set_vat_number().
2636
-	 *
2637
-	 * @since 1.0.19
2638
-	 * @param  string $value var number.
2639
-	 */
2640
-	public function set_user_vat_number( $value ) {
2641
-		$this->set_vat_number( $value );
2788
+     * Alias of self::set_address_confirmed().
2789
+     *
2790
+     * @since 1.0.19
2791
+     * @param  int|bool $value confirmed.
2792
+     */
2793
+    public function set_customer_address_confirmed( $value ) {
2794
+        $this->set_address_confirmed( $value );
2642 2795
     }
2643 2796
 
2644 2797
     /**
2645
-	 * Alias of self::set_vat_number().
2646
-	 *
2647
-	 * @since 1.0.19
2648
-	 * @param  string $value var number.
2649
-	 */
2650
-	public function set_customer_vat_number( $value ) {
2651
-		$this->set_vat_number( $value );
2798
+     * Set the invoice sub total.
2799
+     *
2800
+     * @since 1.0.19
2801
+     * @param  float $value sub total.
2802
+     */
2803
+    public function set_subtotal( $value ) {
2804
+        $this->set_prop( 'subtotal', max( 0, $value ) );
2652 2805
     }
2653 2806
 
2654 2807
     /**
2655
-	 * Set the customer's vat rate.
2656
-	 *
2657
-	 * @since 1.0.19
2658
-	 * @param  string $value var rate.
2659
-	 */
2660
-	public function set_vat_rate( $value ) {
2661
-		$this->set_prop( 'vat_rate', $value );
2808
+     * Set the invoice total.
2809
+     *
2810
+     * @since 1.0.19
2811
+     * @param  float $value sub total.
2812
+     */
2813
+    public function set_total( $value ) {
2814
+        $this->set_prop( 'total', max( 0, $value ) );
2662 2815
     }
2663 2816
 
2664
-    /**
2665
-	 * Alias of self::set_vat_rate().
2666
-	 *
2667
-	 * @since 1.0.19
2668
-	 * @param  string $value var number.
2669
-	 */
2670
-	public function set_user_vat_rate( $value ) {
2671
-		$this->set_vat_rate( $value );
2672
-    }
2673
-
2674
-    /**
2675
-	 * Alias of self::set_vat_rate().
2676
-	 *
2677
-	 * @since 1.0.19
2678
-	 * @param  string $value var number.
2679
-	 */
2680
-	public function set_customer_vat_rate( $value ) {
2681
-		$this->set_vat_rate( $value );
2682
-    }
2683
-
2684
-    /**
2685
-	 * Set the customer's address.
2686
-	 *
2687
-	 * @since 1.0.19
2688
-	 * @param  string $value address.
2689
-	 */
2690
-	public function set_address( $value ) {
2691
-		$this->set_prop( 'address', $value );
2692
-    }
2693
-
2694
-    /**
2695
-	 * Alias of self::set_address().
2696
-	 *
2697
-	 * @since 1.0.19
2698
-	 * @param  string $value address.
2699
-	 */
2700
-	public function set_user_address( $value ) {
2701
-		$this->set_address( $value );
2702
-    }
2703
-
2704
-    /**
2705
-	 * Alias of self::set_address().
2706
-	 *
2707
-	 * @since 1.0.19
2708
-	 * @param  string $value address.
2709
-	 */
2710
-	public function set_customer_address( $value ) {
2711
-		$this->set_address( $value );
2712
-    }
2713
-
2714
-    /**
2715
-	 * Set whether the customer has viewed the invoice or not.
2716
-	 *
2717
-	 * @since 1.0.19
2718
-	 * @param  int|bool $value confirmed.
2719
-	 */
2720
-	public function set_is_viewed( $value ) {
2721
-		$this->set_prop( 'is_viewed', $value );
2722
-	}
2723
-
2724
-	/**
2725
-	 * Set extra email recipients.
2726
-	 *
2727
-	 * @since 1.0.19
2728
-	 * @param  string $value email recipients.
2729
-	 */
2730
-	public function set_email_cc( $value ) {
2731
-		$this->set_prop( 'email_cc', $value );
2732
-	}
2733
-
2734
-	/**
2735
-	 * Set the invoice template.
2736
-	 *
2737
-	 * @since 1.0.19
2738
-	 * @param  string $value template.
2739
-	 */
2740
-	public function set_template( $value ) {
2741
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2742
-			$this->set_prop( 'template', $value );
2743
-		}
2744
-	}
2745
-
2746
-	/**
2747
-	 * Set the invoice source.
2748
-	 *
2749
-	 * @since 1.0.19
2750
-	 * @param  string $value source.
2751
-	 * @deprecated
2752
-	 */
2753
-	public function created_via( $value ) {
2754
-		$this->set_created_via( sanitize_text_field( $value ) );
2755
-	}
2756
-
2757
-	/**
2758
-	 * Set the invoice source.
2759
-	 *
2760
-	 * @since 1.0.19
2761
-	 * @param  string $value source.
2762
-	 */
2763
-	public function set_created_via( $value ) {
2764
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2765
-	}
2766
-
2767
-	/**
2768
-	 * Set the customer's address confirmed status.
2769
-	 *
2770
-	 * @since 1.0.19
2771
-	 * @param  int|bool $value confirmed.
2772
-	 */
2773
-	public function set_address_confirmed( $value ) {
2774
-		$this->set_prop( 'address_confirmed', $value );
2775
-    }
2776
-
2777
-    /**
2778
-	 * Alias of self::set_address_confirmed().
2779
-	 *
2780
-	 * @since 1.0.19
2781
-	 * @param  int|bool $value confirmed.
2782
-	 */
2783
-	public function set_user_address_confirmed( $value ) {
2784
-		$this->set_address_confirmed( $value );
2785
-    }
2786
-
2787
-    /**
2788
-	 * Alias of self::set_address_confirmed().
2789
-	 *
2790
-	 * @since 1.0.19
2791
-	 * @param  int|bool $value confirmed.
2792
-	 */
2793
-	public function set_customer_address_confirmed( $value ) {
2794
-		$this->set_address_confirmed( $value );
2795
-    }
2796
-
2797
-    /**
2798
-	 * Set the invoice sub total.
2799
-	 *
2800
-	 * @since 1.0.19
2801
-	 * @param  float $value sub total.
2802
-	 */
2803
-	public function set_subtotal( $value ) {
2804
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2805
-	}
2806
-
2807
-	/**
2808
-	 * Set the invoice total.
2809
-	 *
2810
-	 * @since 1.0.19
2811
-	 * @param  float $value sub total.
2812
-	 */
2813
-	public function set_total( $value ) {
2814
-		$this->set_prop( 'total', max( 0, $value ) );
2815
-    }
2816
-
2817
-    /**
2818
-	 * Set the invoice discount amount.
2819
-	 *
2820
-	 * @since 1.0.19
2821
-	 * @param  float $value discount total.
2822
-	 */
2823
-	public function set_total_discount( $value ) {
2824
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2817
+    /**
2818
+     * Set the invoice discount amount.
2819
+     *
2820
+     * @since 1.0.19
2821
+     * @param  float $value discount total.
2822
+     */
2823
+    public function set_total_discount( $value ) {
2824
+        $this->set_prop( 'total_discount', max( 0, $value ) );
2825 2825
     }
2826 2826
 
2827 2827
     /**
2828
-	 * Alias of self::set_total_discount().
2829
-	 *
2830
-	 * @since 1.0.19
2831
-	 * @param  float $value discount total.
2832
-	 */
2833
-	public function set_discount( $value ) {
2834
-		$this->set_total_discount( $value );
2828
+     * Alias of self::set_total_discount().
2829
+     *
2830
+     * @since 1.0.19
2831
+     * @param  float $value discount total.
2832
+     */
2833
+    public function set_discount( $value ) {
2834
+        $this->set_total_discount( $value );
2835 2835
     }
2836 2836
 
2837 2837
     /**
2838
-	 * Set the invoice tax amount.
2839
-	 *
2840
-	 * @since 1.0.19
2841
-	 * @param  float $value tax total.
2842
-	 */
2843
-	public function set_total_tax( $value ) {
2844
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2838
+     * Set the invoice tax amount.
2839
+     *
2840
+     * @since 1.0.19
2841
+     * @param  float $value tax total.
2842
+     */
2843
+    public function set_total_tax( $value ) {
2844
+        $this->set_prop( 'total_tax', max( 0, $value ) );
2845 2845
     }
2846 2846
 
2847 2847
     /**
2848
-	 * Alias of self::set_total_tax().
2849
-	 *
2850
-	 * @since 1.0.19
2851
-	 * @param  float $value tax total.
2852
-	 */
2853
-	public function set_tax_total( $value ) {
2854
-		$this->set_total_tax( $value );
2848
+     * Alias of self::set_total_tax().
2849
+     *
2850
+     * @since 1.0.19
2851
+     * @param  float $value tax total.
2852
+     */
2853
+    public function set_tax_total( $value ) {
2854
+        $this->set_total_tax( $value );
2855 2855
     }
2856 2856
 
2857 2857
     /**
2858
-	 * Set the invoice fees amount.
2859
-	 *
2860
-	 * @since 1.0.19
2861
-	 * @param  float $value fees total.
2862
-	 */
2863
-	public function set_total_fees( $value ) {
2864
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2858
+     * Set the invoice fees amount.
2859
+     *
2860
+     * @since 1.0.19
2861
+     * @param  float $value fees total.
2862
+     */
2863
+    public function set_total_fees( $value ) {
2864
+        $this->set_prop( 'total_fees', max( 0, $value ) );
2865 2865
     }
2866 2866
 
2867 2867
     /**
2868
-	 * Alias of self::set_total_fees().
2869
-	 *
2870
-	 * @since 1.0.19
2871
-	 * @param  float $value fees total.
2872
-	 */
2873
-	public function set_fees_total( $value ) {
2874
-		$this->set_total_fees( $value );
2868
+     * Alias of self::set_total_fees().
2869
+     *
2870
+     * @since 1.0.19
2871
+     * @param  float $value fees total.
2872
+     */
2873
+    public function set_fees_total( $value ) {
2874
+        $this->set_total_fees( $value );
2875 2875
     }
2876 2876
 
2877 2877
     /**
2878
-	 * Set the invoice fees.
2879
-	 *
2880
-	 * @since 1.0.19
2881
-	 * @param  array $value fees.
2882
-	 */
2883
-	public function set_fees( $value ) {
2878
+     * Set the invoice fees.
2879
+     *
2880
+     * @since 1.0.19
2881
+     * @param  array $value fees.
2882
+     */
2883
+    public function set_fees( $value ) {
2884 2884
 
2885
-		if ( ! is_array( $value ) ) {
2886
-			$value = array();
2887
-		}
2885
+        if ( ! is_array( $value ) ) {
2886
+            $value = array();
2887
+        }
2888 2888
 
2889
-		$this->set_prop( 'fees', $value );
2889
+        $this->set_prop( 'fees', $value );
2890 2890
 
2891 2891
     }
2892 2892
 
2893 2893
     /**
2894
-	 * Set the invoice taxes.
2895
-	 *
2896
-	 * @since 1.0.19
2897
-	 * @param  array $value taxes.
2898
-	 */
2899
-	public function set_taxes( $value ) {
2894
+     * Set the invoice taxes.
2895
+     *
2896
+     * @since 1.0.19
2897
+     * @param  array $value taxes.
2898
+     */
2899
+    public function set_taxes( $value ) {
2900 2900
 
2901
-		if ( ! is_array( $value ) ) {
2902
-			$value = array();
2903
-		}
2901
+        if ( ! is_array( $value ) ) {
2902
+            $value = array();
2903
+        }
2904 2904
 
2905
-		$this->set_prop( 'taxes', $value );
2905
+        $this->set_prop( 'taxes', $value );
2906 2906
 
2907 2907
     }
2908 2908
 
2909 2909
     /**
2910
-	 * Set the invoice discounts.
2911
-	 *
2912
-	 * @since 1.0.19
2913
-	 * @param  array $value discounts.
2914
-	 */
2915
-	public function set_discounts( $value ) {
2910
+     * Set the invoice discounts.
2911
+     *
2912
+     * @since 1.0.19
2913
+     * @param  array $value discounts.
2914
+     */
2915
+    public function set_discounts( $value ) {
2916 2916
 
2917
-		if ( ! is_array( $value ) ) {
2918
-			$value = array();
2919
-		}
2917
+        if ( ! is_array( $value ) ) {
2918
+            $value = array();
2919
+        }
2920 2920
 
2921
-		$this->set_prop( 'discounts', $value );
2921
+        $this->set_prop( 'discounts', $value );
2922 2922
     }
2923 2923
 
2924 2924
     /**
2925
-	 * Set the invoice items.
2926
-	 *
2927
-	 * @since 1.0.19
2928
-	 * @param  GetPaid_Form_Item[] $value items.
2929
-	 */
2930
-	public function set_items( $value ) {
2925
+     * Set the invoice items.
2926
+     *
2927
+     * @since 1.0.19
2928
+     * @param  GetPaid_Form_Item[] $value items.
2929
+     */
2930
+    public function set_items( $value ) {
2931 2931
 
2932 2932
         // Remove existing items.
2933 2933
         $this->set_prop( 'items', array() );
2934
-		$this->recurring_item = null;
2934
+        $this->recurring_item = null;
2935 2935
 
2936 2936
         // Ensure that we have an array.
2937 2937
         if ( ! is_array( $value ) ) {
@@ -2945,95 +2945,95 @@  discard block
 block discarded – undo
2945 2945
     }
2946 2946
 
2947 2947
     /**
2948
-	 * Set the payment form.
2949
-	 *
2950
-	 * @since 1.0.19
2951
-	 * @param  int $value payment form.
2952
-	 */
2953
-	public function set_payment_form( $value ) {
2954
-		$this->set_prop( 'payment_form', $value );
2948
+     * Set the payment form.
2949
+     *
2950
+     * @since 1.0.19
2951
+     * @param  int $value payment form.
2952
+     */
2953
+    public function set_payment_form( $value ) {
2954
+        $this->set_prop( 'payment_form', $value );
2955 2955
     }
2956 2956
 
2957 2957
     /**
2958
-	 * Set the submission id.
2959
-	 *
2960
-	 * @since 1.0.19
2961
-	 * @param  string $value submission id.
2962
-	 */
2963
-	public function set_submission_id( $value ) {
2964
-		$this->set_prop( 'submission_id', $value );
2958
+     * Set the submission id.
2959
+     *
2960
+     * @since 1.0.19
2961
+     * @param  string $value submission id.
2962
+     */
2963
+    public function set_submission_id( $value ) {
2964
+        $this->set_prop( 'submission_id', $value );
2965 2965
     }
2966 2966
 
2967 2967
     /**
2968
-	 * Set the discount code.
2969
-	 *
2970
-	 * @since 1.0.19
2971
-	 * @param  string $value discount code.
2972
-	 */
2973
-	public function set_discount_code( $value ) {
2974
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
2968
+     * Set the discount code.
2969
+     *
2970
+     * @since 1.0.19
2971
+     * @param  string $value discount code.
2972
+     */
2973
+    public function set_discount_code( $value ) {
2974
+        $this->set_prop( 'discount_code', sanitize_text_field( $value ) );
2975 2975
     }
2976 2976
 
2977 2977
     /**
2978
-	 * Set the gateway.
2979
-	 *
2980
-	 * @since 1.0.19
2981
-	 * @param  string $value gateway.
2982
-	 */
2983
-	public function set_gateway( $value ) {
2984
-		$this->set_prop( 'gateway', $value );
2978
+     * Set the gateway.
2979
+     *
2980
+     * @since 1.0.19
2981
+     * @param  string $value gateway.
2982
+     */
2983
+    public function set_gateway( $value ) {
2984
+        $this->set_prop( 'gateway', $value );
2985 2985
     }
2986 2986
 
2987 2987
     /**
2988
-	 * Set the transaction id.
2989
-	 *
2990
-	 * @since 1.0.19
2991
-	 * @param  string $value transaction id.
2992
-	 */
2993
-	public function set_transaction_id( $value ) {
2994
-		if ( ! empty( $value ) ) {
2995
-			$this->set_prop( 'transaction_id', $value );
2996
-		}
2988
+     * Set the transaction id.
2989
+     *
2990
+     * @since 1.0.19
2991
+     * @param  string $value transaction id.
2992
+     */
2993
+    public function set_transaction_id( $value ) {
2994
+        if ( ! empty( $value ) ) {
2995
+            $this->set_prop( 'transaction_id', $value );
2996
+        }
2997 2997
     }
2998 2998
 
2999 2999
     /**
3000
-	 * Set the currency id.
3001
-	 *
3002
-	 * @since 1.0.19
3003
-	 * @param  string $value currency id.
3004
-	 */
3005
-	public function set_currency( $value ) {
3006
-		$this->set_prop( 'currency', $value );
3000
+     * Set the currency id.
3001
+     *
3002
+     * @since 1.0.19
3003
+     * @param  string $value currency id.
3004
+     */
3005
+    public function set_currency( $value ) {
3006
+        $this->set_prop( 'currency', $value );
3007 3007
     }
3008 3008
 
3009
-	/**
3010
-	 * Set whether to disable taxes.
3011
-	 *
3012
-	 * @since 1.0.19
3013
-	 * @param  bool $value value.
3014
-	 */
3015
-	public function set_disable_taxes( $value ) {
3016
-		$this->set_prop( 'disable_taxes', (bool) $value );
3017
-	}
3009
+    /**
3010
+     * Set whether to disable taxes.
3011
+     *
3012
+     * @since 1.0.19
3013
+     * @param  bool $value value.
3014
+     */
3015
+    public function set_disable_taxes( $value ) {
3016
+        $this->set_prop( 'disable_taxes', (bool) $value );
3017
+    }
3018 3018
 
3019 3019
     /**
3020
-	 * Set the subscription id.
3021
-	 *
3022
-	 * @since 1.0.19
3023
-	 * @param  string $value subscription id.
3024
-	 */
3025
-	public function set_subscription_id( $value ) {
3026
-		$this->set_prop( 'subscription_id', $value );
3027
-	}
3020
+     * Set the subscription id.
3021
+     *
3022
+     * @since 1.0.19
3023
+     * @param  string $value subscription id.
3024
+     */
3025
+    public function set_subscription_id( $value ) {
3026
+        $this->set_prop( 'subscription_id', $value );
3027
+    }
3028 3028
 	
3029
-	/**
3030
-	 * Set the remote subscription id.
3031
-	 *
3032
-	 * @since 1.0.19
3033
-	 * @param  string $value subscription id.
3034
-	 */
3035
-	public function set_remote_subscription_id( $value ) {
3036
-		$this->set_prop( 'remote_subscription_id', $value );
3029
+    /**
3030
+     * Set the remote subscription id.
3031
+     *
3032
+     * @since 1.0.19
3033
+     * @param  string $value subscription id.
3034
+     */
3035
+    public function set_remote_subscription_id( $value ) {
3036
+        $this->set_prop( 'remote_subscription_id', $value );
3037 3037
     }
3038 3038
 
3039 3039
     /*
@@ -3072,24 +3072,24 @@  discard block
 block discarded – undo
3072 3072
      */
3073 3073
     public function is_taxable() {
3074 3074
         return ! $this->get_disable_taxes();
3075
-	}
3075
+    }
3076 3076
 
3077
-	/**
3078
-	 * @deprecated
3079
-	 */
3080
-	public function has_vat() {
3077
+    /**
3078
+     * @deprecated
3079
+     */
3080
+    public function has_vat() {
3081 3081
         return $this->is_taxable();
3082
-	}
3082
+    }
3083 3083
 
3084
-	/**
3085
-	 * Checks to see if the invoice requires payment.
3086
-	 */
3087
-	public function is_free() {
3084
+    /**
3085
+     * Checks to see if the invoice requires payment.
3086
+     */
3087
+    public function is_free() {
3088 3088
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3089 3089
 
3090
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3091
-			$is_free = false;
3092
-		}
3090
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3091
+            $is_free = false;
3092
+        }
3093 3093
 
3094 3094
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3095 3095
     }
@@ -3100,46 +3100,46 @@  discard block
 block discarded – undo
3100 3100
     public function is_paid() {
3101 3101
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3102 3102
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3103
-	}
3103
+    }
3104 3104
 
3105
-	/**
3105
+    /**
3106 3106
      * Checks if the invoice needs payment.
3107 3107
      */
3108
-	public function needs_payment() {
3109
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3108
+    public function needs_payment() {
3109
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3110 3110
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3111 3111
     }
3112 3112
   
3113
-	/**
3113
+    /**
3114 3114
      * Checks if the invoice is refunded.
3115 3115
      */
3116
-	public function is_refunded() {
3116
+    public function is_refunded() {
3117 3117
         $is_refunded = $this->has_status( 'wpi-refunded' );
3118 3118
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3119
-	}
3119
+    }
3120 3120
 
3121
-	/**
3121
+    /**
3122 3122
      * Checks if the invoice is held.
3123 3123
      */
3124
-	public function is_held() {
3124
+    public function is_held() {
3125 3125
         $is_held = $this->has_status( 'wpi-onhold' );
3126 3126
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3127
-	}
3127
+    }
3128 3128
 
3129
-	/**
3129
+    /**
3130 3130
      * Checks if the invoice is due.
3131 3131
      */
3132
-	public function is_due() {
3133
-		$due_date = $this->get_due_date();
3134
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3135
-	}
3132
+    public function is_due() {
3133
+        $due_date = $this->get_due_date();
3134
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3135
+    }
3136 3136
 
3137
-	/**
3137
+    /**
3138 3138
      * Checks if the invoice is draft.
3139 3139
      */
3140
-	public function is_draft() {
3140
+    public function is_draft() {
3141 3141
         return $this->has_status( 'draft, auto-draft' );
3142
-	}
3142
+    }
3143 3143
 
3144 3144
     /**
3145 3145
      * Checks if the invoice has a given status.
@@ -3147,9 +3147,9 @@  discard block
 block discarded – undo
3147 3147
     public function has_status( $status ) {
3148 3148
         $status = wpinv_parse_list( $status );
3149 3149
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3150
-	}
3150
+    }
3151 3151
 
3152
-	/**
3152
+    /**
3153 3153
      * Checks if the invoice is of a given type.
3154 3154
      */
3155 3155
     public function is_type( $type ) {
@@ -3172,25 +3172,25 @@  discard block
 block discarded – undo
3172 3172
      */
3173 3173
     public function has_free_trial() {
3174 3174
         return $this->is_recurring() && 0 == $this->get_initial_total();
3175
-	}
3175
+    }
3176 3176
 
3177
-	/**
3177
+    /**
3178 3178
      * @deprecated
3179 3179
      */
3180 3180
     public function is_free_trial() {
3181 3181
         $this->has_free_trial();
3182 3182
     }
3183 3183
 
3184
-	/**
3184
+    /**
3185 3185
      * Check if the initial payment if 0.
3186 3186
      *
3187 3187
      */
3188
-	public function is_initial_free() {
3188
+    public function is_initial_free() {
3189 3189
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3190 3190
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3191 3191
     }
3192 3192
 	
3193
-	/**
3193
+    /**
3194 3194
      * Check if the recurring item has a free trial.
3195 3195
      *
3196 3196
      */
@@ -3203,21 +3203,21 @@  discard block
 block discarded – undo
3203 3203
 
3204 3204
         $item = $this->get_recurring( true );
3205 3205
         return $item->has_free_trial();
3206
-	}
3206
+    }
3207 3207
 
3208
-	/**
3208
+    /**
3209 3209
      * Check if the free trial is a result of a discount.
3210 3210
      */
3211 3211
     public function is_free_trial_from_discount() {
3212
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3213
-	}
3212
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3213
+    }
3214 3214
 	
3215
-	/**
3215
+    /**
3216 3216
      * @deprecated
3217 3217
      */
3218 3218
     public function discount_first_payment_only() {
3219 3219
 
3220
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3220
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3221 3221
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3222 3222
             return true;
3223 3223
         }
@@ -3242,147 +3242,147 @@  discard block
 block discarded – undo
3242 3242
      */
3243 3243
     public function add_item( $item ) {
3244 3244
 
3245
-		if ( is_array( $item ) ) {
3246
-			$item = $this->process_array_item( $item );
3247
-		}
3245
+        if ( is_array( $item ) ) {
3246
+            $item = $this->process_array_item( $item );
3247
+        }
3248 3248
 
3249
-		if ( is_numeric( $item ) ) {
3250
-			$item = new GetPaid_Form_Item( $item );
3251
-		}
3249
+        if ( is_numeric( $item ) ) {
3250
+            $item = new GetPaid_Form_Item( $item );
3251
+        }
3252 3252
 
3253 3253
         // Make sure that it is available for purchase.
3254
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3255
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3254
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3255
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3256 3256
         }
3257 3257
 
3258 3258
         // Do we have a recurring item?
3259
-		if ( $item->is_recurring() ) {
3260
-			$this->recurring_item = $item->get_id();
3259
+        if ( $item->is_recurring() ) {
3260
+            $this->recurring_item = $item->get_id();
3261 3261
         }
3262 3262
 
3263 3263
         // Invoice id.
3264 3264
         $item->invoice_id = (int) $this->get_id();
3265 3265
 
3266
-		// Remove duplicates.
3267
-		$this->remove_item( $item->get_id() );
3266
+        // Remove duplicates.
3267
+        $this->remove_item( $item->get_id() );
3268 3268
 
3269
-		if ( 0 == $item->get_quantity() ) {
3270
-			return;
3271
-		}
3269
+        if ( 0 == $item->get_quantity() ) {
3270
+            return;
3271
+        }
3272 3272
 
3273
-		// Retrieve all items.
3273
+        // Retrieve all items.
3274 3274
         $items   = $this->get_items();
3275 3275
 
3276
-		// Add new item.
3276
+        // Add new item.
3277 3277
         $items[] = $item;
3278 3278
 
3279 3279
         $this->set_prop( 'items', $items );
3280 3280
 
3281
-		return true;
3282
-	}
3281
+        return true;
3282
+    }
3283 3283
 
3284
-	/**
3285
-	 * Converts an array to an item.
3286
-	 *
3287
-	 * @since 1.0.19
3288
-	 * @return GetPaid_Form_Item
3289
-	 */
3290
-	protected function process_array_item( $array ) {
3284
+    /**
3285
+     * Converts an array to an item.
3286
+     *
3287
+     * @since 1.0.19
3288
+     * @return GetPaid_Form_Item
3289
+     */
3290
+    protected function process_array_item( $array ) {
3291 3291
 
3292
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3293
-		$item    = new GetPaid_Form_Item( $item_id );
3292
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3293
+        $item    = new GetPaid_Form_Item( $item_id );
3294 3294
 
3295
-		// Set item data.
3296
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3297
-			if ( isset( $array[ "item_$key" ] ) ) {
3298
-				$method = "set_$key";
3299
-				$item->$method( $array[ "item_$key" ] );
3300
-			}
3301
-		}
3295
+        // Set item data.
3296
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3297
+            if ( isset( $array[ "item_$key" ] ) ) {
3298
+                $method = "set_$key";
3299
+                $item->$method( $array[ "item_$key" ] );
3300
+            }
3301
+        }
3302 3302
 
3303
-		if ( isset( $array['quantity'] ) ) {
3304
-			$item->set_quantity( $array['quantity'] );
3305
-		}
3303
+        if ( isset( $array['quantity'] ) ) {
3304
+            $item->set_quantity( $array['quantity'] );
3305
+        }
3306 3306
 
3307
-		// Set item meta.
3308
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3309
-			$item->set_item_meta( $array['meta'] );
3310
-		}
3307
+        // Set item meta.
3308
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3309
+            $item->set_item_meta( $array['meta'] );
3310
+        }
3311 3311
 
3312
-		return $item;
3312
+        return $item;
3313 3313
 
3314
-	}
3314
+    }
3315 3315
 
3316 3316
     /**
3317
-	 * Retrieves a specific item.
3318
-	 *
3319
-	 * @since 1.0.19
3320
-	 * @return GetPaid_Form_Item|null
3321
-	 */
3322
-	public function get_item( $item_id ) {
3317
+     * Retrieves a specific item.
3318
+     *
3319
+     * @since 1.0.19
3320
+     * @return GetPaid_Form_Item|null
3321
+     */
3322
+    public function get_item( $item_id ) {
3323 3323
 
3324
-		foreach ( $this->get_items() as $item ) {
3325
-			if ( (int) $item_id == $item->get_id() ) {
3326
-				return $item;
3327
-			}
3328
-		}
3324
+        foreach ( $this->get_items() as $item ) {
3325
+            if ( (int) $item_id == $item->get_id() ) {
3326
+                return $item;
3327
+            }
3328
+        }
3329 3329
 
3330
-		return null;
3330
+        return null;
3331 3331
     }
3332 3332
 
3333 3333
     /**
3334
-	 * Removes a specific item.
3335
-	 *
3336
-	 * @since 1.0.19
3337
-	 */
3338
-	public function remove_item( $item_id ) {
3339
-		$items   = $this->get_items();
3340
-		$item_id = (int) $item_id;
3334
+     * Removes a specific item.
3335
+     *
3336
+     * @since 1.0.19
3337
+     */
3338
+    public function remove_item( $item_id ) {
3339
+        $items   = $this->get_items();
3340
+        $item_id = (int) $item_id;
3341 3341
 
3342
-		foreach ( $items as $index => $item ) {
3343
-			if ( (int) $item_id == $item->get_id() ) {
3344
-				unset( $items[ $index ] );
3345
-				$this->set_prop( 'items', $items );
3342
+        foreach ( $items as $index => $item ) {
3343
+            if ( (int) $item_id == $item->get_id() ) {
3344
+                unset( $items[ $index ] );
3345
+                $this->set_prop( 'items', $items );
3346 3346
 
3347
-				if ( $item_id == $this->recurring_item ) {
3348
-					$this->recurring_item = null;
3349
-				}
3347
+                if ( $item_id == $this->recurring_item ) {
3348
+                    $this->recurring_item = null;
3349
+                }
3350 3350
 
3351
-			}
3352
-		}
3351
+            }
3352
+        }
3353 3353
 
3354 3354
     }
3355 3355
 
3356 3356
     /**
3357
-	 * Adds a fee to the invoice.
3358
-	 *
3359
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3360
-	 * @since 1.0.19
3361
-	 */
3357
+     * Adds a fee to the invoice.
3358
+     *
3359
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3360
+     * @since 1.0.19
3361
+     */
3362 3362
     public function add_fee( $fee ) {
3363 3363
 
3364
-		$fees                 = $this->get_fees();
3365
-		$fees[ $fee['name'] ] = $fee;
3366
-		$this->set_prop( 'fees', $fees );
3364
+        $fees                 = $this->get_fees();
3365
+        $fees[ $fee['name'] ] = $fee;
3366
+        $this->set_prop( 'fees', $fees );
3367 3367
 
3368 3368
     }
3369 3369
 
3370 3370
     /**
3371
-	 * Retrieves a specific fee.
3372
-	 *
3373
-	 * @since 1.0.19
3374
-	 */
3375
-	public function get_fee( $fee ) {
3371
+     * Retrieves a specific fee.
3372
+     *
3373
+     * @since 1.0.19
3374
+     */
3375
+    public function get_fee( $fee ) {
3376 3376
         $fees = $this->get_fees();
3377
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3377
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3378 3378
     }
3379 3379
 
3380 3380
     /**
3381
-	 * Removes a specific fee.
3382
-	 *
3383
-	 * @since 1.0.19
3384
-	 */
3385
-	public function remove_fee( $fee ) {
3381
+     * Removes a specific fee.
3382
+     *
3383
+     * @since 1.0.19
3384
+     */
3385
+    public function remove_fee( $fee ) {
3386 3386
         $fees = $this->get_fees();
3387 3387
         if ( isset( $fees[ $fee ] ) ) {
3388 3388
             unset( $fees[ $fee ] );
@@ -3390,55 +3390,55 @@  discard block
 block discarded – undo
3390 3390
         }
3391 3391
     }
3392 3392
 
3393
-	/**
3394
-	 * Adds a discount to the invoice.
3395
-	 *
3396
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3397
-	 * @since 1.0.19
3398
-	 */
3399
-	public function add_discount( $discount ) {
3393
+    /**
3394
+     * Adds a discount to the invoice.
3395
+     *
3396
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3397
+     * @since 1.0.19
3398
+     */
3399
+    public function add_discount( $discount ) {
3400 3400
 
3401
-		$discounts = $this->get_discounts();
3402
-		$discounts[ $discount['name'] ] = $discount;
3403
-		$this->set_prop( 'discounts', $discounts );
3401
+        $discounts = $this->get_discounts();
3402
+        $discounts[ $discount['name'] ] = $discount;
3403
+        $this->set_prop( 'discounts', $discounts );
3404 3404
 
3405
-	}
3405
+    }
3406 3406
 
3407 3407
     /**
3408
-	 * Retrieves a specific discount.
3409
-	 *
3410
-	 * @since 1.0.19
3411
-	 * @return float
3412
-	 */
3413
-	public function get_discount( $discount = false ) {
3408
+     * Retrieves a specific discount.
3409
+     *
3410
+     * @since 1.0.19
3411
+     * @return float
3412
+     */
3413
+    public function get_discount( $discount = false ) {
3414 3414
 
3415
-		// Backwards compatibilty.
3416
-		if ( empty( $discount ) ) {
3417
-			return $this->get_total_discount();
3418
-		}
3415
+        // Backwards compatibilty.
3416
+        if ( empty( $discount ) ) {
3417
+            return $this->get_total_discount();
3418
+        }
3419 3419
 
3420 3420
         $discounts = $this->get_discounts();
3421
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3421
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3422 3422
     }
3423 3423
 
3424 3424
     /**
3425
-	 * Removes a specific discount.
3426
-	 *
3427
-	 * @since 1.0.19
3428
-	 */
3429
-	public function remove_discount( $discount ) {
3425
+     * Removes a specific discount.
3426
+     *
3427
+     * @since 1.0.19
3428
+     */
3429
+    public function remove_discount( $discount ) {
3430 3430
         $discounts = $this->get_discounts();
3431 3431
         if ( isset( $discounts[ $discount ] ) ) {
3432 3432
             unset( $discounts[ $discount ] );
3433 3433
             $this->set_prop( 'discounts', $discounts );
3434 3434
         }
3435 3435
 
3436
-		if ( 'discount_code' == $discount ) {
3437
-			foreach ( $this->get_items() as $item ) {
3438
-				$item->item_discount           = 0;
3439
-				$item->recurring_item_discount = 0;
3440
-			}
3441
-		}
3436
+        if ( 'discount_code' == $discount ) {
3437
+            foreach ( $this->get_items() as $item ) {
3438
+                $item->item_discount           = 0;
3439
+                $item->recurring_item_discount = 0;
3440
+            }
3441
+        }
3442 3442
 
3443 3443
     }
3444 3444
 
@@ -3451,34 +3451,34 @@  discard block
 block discarded – undo
3451 3451
         if ( $this->is_taxable() ) {
3452 3452
 
3453 3453
             $taxes                 = $this->get_taxes();
3454
-			$taxes[ $tax['name'] ] = $tax;
3455
-			$this->set_prop( 'taxes', $tax );
3454
+            $taxes[ $tax['name'] ] = $tax;
3455
+            $this->set_prop( 'taxes', $tax );
3456 3456
 
3457 3457
         }
3458 3458
     }
3459 3459
 
3460 3460
     /**
3461
-	 * Retrieves a specific tax.
3462
-	 *
3463
-	 * @since 1.0.19
3464
-	 */
3465
-	public function get_tax( $tax = null ) {
3461
+     * Retrieves a specific tax.
3462
+     *
3463
+     * @since 1.0.19
3464
+     */
3465
+    public function get_tax( $tax = null ) {
3466 3466
 
3467
-		// Backwards compatility.
3468
-		if ( empty( $tax ) ) {
3469
-			return $this->get_total_tax();
3470
-		}
3467
+        // Backwards compatility.
3468
+        if ( empty( $tax ) ) {
3469
+            return $this->get_total_tax();
3470
+        }
3471 3471
 
3472 3472
         $taxes = $this->get_taxes();
3473
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3473
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3474 3474
     }
3475 3475
 
3476 3476
     /**
3477
-	 * Removes a specific tax.
3478
-	 *
3479
-	 * @since 1.0.19
3480
-	 */
3481
-	public function remove_tax( $tax ) {
3477
+     * Removes a specific tax.
3478
+     *
3479
+     * @since 1.0.19
3480
+     */
3481
+    public function remove_tax( $tax ) {
3482 3482
         $taxes = $this->get_taxes();
3483 3483
         if ( isset( $taxes[ $tax ] ) ) {
3484 3484
             unset( $taxes[ $tax ] );
@@ -3487,185 +3487,185 @@  discard block
 block discarded – undo
3487 3487
     }
3488 3488
 
3489 3489
     /**
3490
-	 * Recalculates the invoice subtotal.
3491
-	 *
3492
-	 * @since 1.0.19
3493
-	 * @return float The recalculated subtotal
3494
-	 */
3495
-	public function recalculate_subtotal() {
3490
+     * Recalculates the invoice subtotal.
3491
+     *
3492
+     * @since 1.0.19
3493
+     * @return float The recalculated subtotal
3494
+     */
3495
+    public function recalculate_subtotal() {
3496 3496
         $items     = $this->get_items();
3497
-		$subtotal  = 0;
3498
-		$recurring = 0;
3497
+        $subtotal  = 0;
3498
+        $recurring = 0;
3499 3499
 
3500 3500
         foreach ( $items as $item ) {
3501
-			$subtotal  += $item->get_sub_total( 'edit' );
3502
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3501
+            $subtotal  += $item->get_sub_total( 'edit' );
3502
+            $recurring += $item->get_recurring_sub_total( 'edit' );
3503 3503
         }
3504 3504
 
3505
-		if ( wpinv_prices_include_tax() ) {
3506
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3507
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3508
-		}
3505
+        if ( wpinv_prices_include_tax() ) {
3506
+            $subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3507
+            $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3508
+        }
3509 3509
 
3510
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3511
-		$this->set_subtotal( $current );
3510
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3511
+        $this->set_subtotal( $current );
3512 3512
 
3513
-		$this->totals['subtotal'] = array(
3514
-			'initial'   => $subtotal,
3515
-			'recurring' => $recurring,
3516
-		);
3513
+        $this->totals['subtotal'] = array(
3514
+            'initial'   => $subtotal,
3515
+            'recurring' => $recurring,
3516
+        );
3517 3517
 
3518 3518
         return $current;
3519 3519
     }
3520 3520
 
3521 3521
     /**
3522
-	 * Recalculates the invoice discount total.
3523
-	 *
3524
-	 * @since 1.0.19
3525
-	 * @return float The recalculated discount
3526
-	 */
3527
-	public function recalculate_total_discount() {
3522
+     * Recalculates the invoice discount total.
3523
+     *
3524
+     * @since 1.0.19
3525
+     * @return float The recalculated discount
3526
+     */
3527
+    public function recalculate_total_discount() {
3528 3528
         $discounts = $this->get_discounts();
3529
-		$discount  = 0;
3530
-		$recurring = 0;
3529
+        $discount  = 0;
3530
+        $recurring = 0;
3531 3531
 
3532 3532
         foreach ( $discounts as $data ) {
3533
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3534
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3535
-		}
3533
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3534
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3535
+        }
3536 3536
 
3537
-		$current = $this->is_renewal() ? $recurring : $discount;
3537
+        $current = $this->is_renewal() ? $recurring : $discount;
3538 3538
 
3539
-		$this->set_total_discount( $current );
3539
+        $this->set_total_discount( $current );
3540 3540
 
3541
-		$this->totals['discount'] = array(
3542
-			'initial'   => $discount,
3543
-			'recurring' => $recurring,
3544
-		);
3541
+        $this->totals['discount'] = array(
3542
+            'initial'   => $discount,
3543
+            'recurring' => $recurring,
3544
+        );
3545 3545
 
3546
-		return $current;
3546
+        return $current;
3547 3547
 
3548 3548
     }
3549 3549
 
3550 3550
     /**
3551
-	 * Recalculates the invoice tax total.
3552
-	 *
3553
-	 * @since 1.0.19
3554
-	 * @return float The recalculated tax
3555
-	 */
3556
-	public function recalculate_total_tax() {
3551
+     * Recalculates the invoice tax total.
3552
+     *
3553
+     * @since 1.0.19
3554
+     * @return float The recalculated tax
3555
+     */
3556
+    public function recalculate_total_tax() {
3557 3557
 
3558
-		// Maybe disable taxes.
3559
-		$vat_number = $this->get_vat_number();
3560
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3558
+        // Maybe disable taxes.
3559
+        $vat_number = $this->get_vat_number();
3560
+        $skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3561 3561
 
3562
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3563
-			$skip_tax = false;
3564
-		}
3562
+        if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3563
+            $skip_tax = false;
3564
+        }
3565 3565
 
3566
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3566
+        if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3567 3567
 
3568
-			$this->totals['tax'] = array(
3569
-				'initial'   => 0,
3570
-				'recurring' => 0,
3571
-			);
3568
+            $this->totals['tax'] = array(
3569
+                'initial'   => 0,
3570
+                'recurring' => 0,
3571
+            );
3572 3572
 
3573
-			$this->tax_rate = 0;
3573
+            $this->tax_rate = 0;
3574 3574
 
3575
-			$this->set_taxes( array() );
3576
-			$current = 0;
3577
-		} else {
3575
+            $this->set_taxes( array() );
3576
+            $current = 0;
3577
+        } else {
3578 3578
 
3579
-			$item_taxes = array();
3579
+            $item_taxes = array();
3580 3580
 
3581
-			foreach ( $this->get_items() as $item ) {
3582
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3583
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3584
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3585
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3586
-				foreach ( $taxes as $name => $amount ) {
3587
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3588
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3581
+            foreach ( $this->get_items() as $item ) {
3582
+                $rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3583
+                $rates    = getpaid_filter_item_tax_rates( $item, $rates );
3584
+                $taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3585
+                $r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3586
+                foreach ( $taxes as $name => $amount ) {
3587
+                    $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3588
+                    $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3589 3589
 
3590
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3591
-						$item_taxes[ $name ] = $tax;
3592
-						continue;
3593
-					}
3590
+                    if ( ! isset( $item_taxes[ $name ] ) ) {
3591
+                        $item_taxes[ $name ] = $tax;
3592
+                        continue;
3593
+                    }
3594 3594
 
3595
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3596
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3595
+                    $item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3596
+                    $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3597 3597
 
3598
-				}
3598
+                }
3599 3599
 
3600
-			}
3600
+            }
3601 3601
 
3602
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3603
-			$this->set_taxes( $item_taxes );
3602
+            $item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3603
+            $this->set_taxes( $item_taxes );
3604 3604
 
3605
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3606
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3605
+            $initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3606
+            $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3607 3607
 
3608
-			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3608
+            $current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3609 3609
 
3610
-			$this->totals['tax'] = array(
3611
-				'initial'   => $initial_tax,
3612
-				'recurring' => $recurring_tax,
3613
-			);
3610
+            $this->totals['tax'] = array(
3611
+                'initial'   => $initial_tax,
3612
+                'recurring' => $recurring_tax,
3613
+            );
3614 3614
 
3615
-		}
3615
+        }
3616 3616
 
3617
-		$this->set_total_tax( $current );
3617
+        $this->set_total_tax( $current );
3618 3618
 
3619
-		return $current;
3619
+        return $current;
3620 3620
 
3621 3621
     }
3622 3622
 
3623 3623
     /**
3624
-	 * Recalculates the invoice fees total.
3625
-	 *
3626
-	 * @since 1.0.19
3627
-	 * @return float The recalculated fee
3628
-	 */
3629
-	public function recalculate_total_fees() {
3630
-		$fees      = $this->get_fees();
3631
-		$fee       = 0;
3632
-		$recurring = 0;
3624
+     * Recalculates the invoice fees total.
3625
+     *
3626
+     * @since 1.0.19
3627
+     * @return float The recalculated fee
3628
+     */
3629
+    public function recalculate_total_fees() {
3630
+        $fees      = $this->get_fees();
3631
+        $fee       = 0;
3632
+        $recurring = 0;
3633 3633
 
3634 3634
         foreach ( $fees as $data ) {
3635
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3636
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3637
-		}
3635
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3636
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3637
+        }
3638 3638
 
3639
-		$current = $this->is_renewal() ? $recurring : $fee;
3640
-		$this->set_total_fees( $current );
3639
+        $current = $this->is_renewal() ? $recurring : $fee;
3640
+        $this->set_total_fees( $current );
3641 3641
 
3642
-		$this->totals['fee'] = array(
3643
-			'initial'   => $fee,
3644
-			'recurring' => $recurring,
3645
-		);
3642
+        $this->totals['fee'] = array(
3643
+            'initial'   => $fee,
3644
+            'recurring' => $recurring,
3645
+        );
3646 3646
 
3647 3647
         $this->set_total_fees( $fee );
3648 3648
         return $current;
3649 3649
     }
3650 3650
 
3651 3651
     /**
3652
-	 * Recalculates the invoice total.
3653
-	 *
3654
-	 * @since 1.0.19
3652
+     * Recalculates the invoice total.
3653
+     *
3654
+     * @since 1.0.19
3655 3655
      * @return float The invoice total
3656
-	 */
3657
-	public function recalculate_total() {
3656
+     */
3657
+    public function recalculate_total() {
3658 3658
         $this->recalculate_total_fees();
3659 3659
         $this->recalculate_total_discount();
3660
-		$this->recalculate_total_tax();
3661
-		$this->recalculate_subtotal();
3662
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3663
-		return $this->get_total();
3664
-	}
3665
-
3666
-	/**
3667
-	 * @deprecated
3668
-	 */
3660
+        $this->recalculate_total_tax();
3661
+        $this->recalculate_subtotal();
3662
+        $this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3663
+        return $this->get_total();
3664
+    }
3665
+
3666
+    /**
3667
+     * @deprecated
3668
+     */
3669 3669
     public function recalculate_totals() {
3670 3670
         $this->recalculate_total();
3671 3671
         $this->save( true );
@@ -3679,22 +3679,22 @@  discard block
 block discarded – undo
3679 3679
         return $this->get_data();
3680 3680
     }
3681 3681
 
3682
-	/**
3682
+    /**
3683 3683
      * Adds a system note to an invoice.
3684 3684
      *
3685 3685
      * @param string $note The note being added.
3686
-	 * @return int|false The new note's ID on success, false on failure.
3686
+     * @return int|false The new note's ID on success, false on failure.
3687 3687
      *
3688 3688
      */
3689 3689
     public function add_system_note( $note ) {
3690
-		return $this->add_note( $note, false, false, true );
3691
-	}
3690
+        return $this->add_note( $note, false, false, true );
3691
+    }
3692 3692
 
3693 3693
     /**
3694 3694
      * Adds a note to an invoice.
3695 3695
      *
3696 3696
      * @param string $note The note being added.
3697
-	 * @return int|false The new note's ID on success, false on failure.
3697
+     * @return int|false The new note's ID on success, false on failure.
3698 3698
      *
3699 3699
      */
3700 3700
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3704,21 +3704,21 @@  discard block
 block discarded – undo
3704 3704
             return false;
3705 3705
         }
3706 3706
 
3707
-		$author       = 'System';
3708
-		$author_email = '[email protected]';
3707
+        $author       = 'System';
3708
+        $author_email = '[email protected]';
3709 3709
 
3710
-		// If this is an admin comment or it has been added by the user.
3711
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3712
-			$user         = get_user_by( 'id', get_current_user_id() );
3710
+        // If this is an admin comment or it has been added by the user.
3711
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3712
+            $user         = get_user_by( 'id', get_current_user_id() );
3713 3713
             $author       = $user->display_name;
3714 3714
             $author_email = $user->user_email;
3715
-		}
3715
+        }
3716 3716
 
3717
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3717
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3718 3718
 
3719
-	}
3719
+    }
3720 3720
 
3721
-	/**
3721
+    /**
3722 3722
      * Generates a unique key for the invoice.
3723 3723
      */
3724 3724
     public function generate_key( $string = '' ) {
@@ -3738,113 +3738,113 @@  discard block
 block discarded – undo
3738 3738
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3739 3739
         }
3740 3740
 
3741
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3742
-
3743
-	}
3744
-
3745
-	/**
3746
-	 * Handle the status transition.
3747
-	 */
3748
-	protected function status_transition() {
3749
-		$status_transition = $this->status_transition;
3750
-
3751
-		// Reset status transition variable.
3752
-		$this->status_transition = false;
3741
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3753 3742
 
3754
-		if ( $status_transition ) {
3755
-			try {
3756
-
3757
-				// Fire a hook for the status change.
3758
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3759
-
3760
-				// @deprecated this is deprecated and will be removed in the future.
3761
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3762
-
3763
-				if ( ! empty( $status_transition['from'] ) ) {
3764
-
3765
-					/* translators: 1: old invoice status 2: new invoice status */
3766
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3767
-
3768
-					// Fire another hook.
3769
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3770
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3771
-
3772
-					// @deprecated this is deprecated and will be removed in the future.
3773
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3774
-
3775
-					// Note the transition occurred.
3776
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3777
-
3778
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3779
-					if (
3780
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3781
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3782
-					) {
3783
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3784
-					}
3785
-
3786
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3787
-					if (
3788
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3789
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3790
-					) {
3791
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3792
-					}
3793
-				} else {
3794
-					/* translators: %s: new invoice status */
3795
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3796
-
3797
-					// Note the transition occurred.
3798
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3743
+    }
3799 3744
 
3800
-				}
3801
-			} catch ( Exception $e ) {
3802
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3803
-			}
3804
-		}
3805
-	}
3745
+    /**
3746
+     * Handle the status transition.
3747
+     */
3748
+    protected function status_transition() {
3749
+        $status_transition = $this->status_transition;
3750
+
3751
+        // Reset status transition variable.
3752
+        $this->status_transition = false;
3753
+
3754
+        if ( $status_transition ) {
3755
+            try {
3756
+
3757
+                // Fire a hook for the status change.
3758
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3759
+
3760
+                // @deprecated this is deprecated and will be removed in the future.
3761
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3762
+
3763
+                if ( ! empty( $status_transition['from'] ) ) {
3764
+
3765
+                    /* translators: 1: old invoice status 2: new invoice status */
3766
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3767
+
3768
+                    // Fire another hook.
3769
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3770
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3771
+
3772
+                    // @deprecated this is deprecated and will be removed in the future.
3773
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3774
+
3775
+                    // Note the transition occurred.
3776
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3777
+
3778
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3779
+                    if (
3780
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3781
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3782
+                    ) {
3783
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3784
+                    }
3785
+
3786
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3787
+                    if (
3788
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3789
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3790
+                    ) {
3791
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3792
+                    }
3793
+                } else {
3794
+                    /* translators: %s: new invoice status */
3795
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3796
+
3797
+                    // Note the transition occurred.
3798
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3799
+
3800
+                }
3801
+            } catch ( Exception $e ) {
3802
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3803
+            }
3804
+        }
3805
+    }
3806 3806
 
3807
-	/**
3808
-	 * Updates an invoice status.
3809
-	 */
3810
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3807
+    /**
3808
+     * Updates an invoice status.
3809
+     */
3810
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3811 3811
 
3812
-		// Fires before updating a status.
3813
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3812
+        // Fires before updating a status.
3813
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3814 3814
 
3815
-		// Update the status.
3816
-		$this->set_status( $new_status, $note, $manual );
3815
+        // Update the status.
3816
+        $this->set_status( $new_status, $note, $manual );
3817 3817
 
3818
-		// Save the order.
3819
-		return $this->save();
3818
+        // Save the order.
3819
+        return $this->save();
3820 3820
 
3821
-	}
3821
+    }
3822 3822
 
3823
-	/**
3824
-	 * @deprecated
3825
-	 */
3826
-	public function refresh_item_ids() {
3823
+    /**
3824
+     * @deprecated
3825
+     */
3826
+    public function refresh_item_ids() {
3827 3827
         $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3828 3828
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3829
-	}
3829
+    }
3830 3830
 
3831
-	/**
3832
-	 * @deprecated
3833
-	 */
3834
-	public function update_items( $temp = false ) {
3831
+    /**
3832
+     * @deprecated
3833
+     */
3834
+    public function update_items( $temp = false ) {
3835 3835
 
3836
-		$this->set_items( $this->get_items() );
3836
+        $this->set_items( $this->get_items() );
3837 3837
 
3838
-		if ( ! $temp ) {
3839
-			$this->save();
3840
-		}
3838
+        if ( ! $temp ) {
3839
+            $this->save();
3840
+        }
3841 3841
 
3842 3842
         return $this;
3843
-	}
3843
+    }
3844 3844
 
3845
-	/**
3846
-	 * @deprecated
3847
-	 */
3845
+    /**
3846
+     * @deprecated
3847
+     */
3848 3848
     public function validate_discount() {
3849 3849
 
3850 3850
         $discount_code = $this->get_discount_code();
@@ -3860,93 +3860,93 @@  discard block
 block discarded – undo
3860 3860
 
3861 3861
     }
3862 3862
 
3863
-	/**
3864
-	 * Refunds an invoice.
3865
-	 */
3863
+    /**
3864
+     * Refunds an invoice.
3865
+     */
3866 3866
     public function refund() {
3867
-		$this->set_status( 'wpi-refunded' );
3867
+        $this->set_status( 'wpi-refunded' );
3868 3868
         $this->save();
3869
-	}
3869
+    }
3870 3870
 
3871
-	/**
3872
-	 * Marks an invoice as paid.
3873
-	 * 
3874
-	 * @param string $transaction_id
3875
-	 */
3871
+    /**
3872
+     * Marks an invoice as paid.
3873
+     * 
3874
+     * @param string $transaction_id
3875
+     */
3876 3876
     public function mark_paid( $transaction_id = null, $note = '' ) {
3877 3877
 
3878
-		// Set the transaction id.
3879
-		if ( empty( $transaction_id ) ) {
3880
-			$transaction_id = $this->generate_key('trans_');
3881
-		}
3878
+        // Set the transaction id.
3879
+        if ( empty( $transaction_id ) ) {
3880
+            $transaction_id = $this->generate_key('trans_');
3881
+        }
3882 3882
 
3883
-		if ( ! $this->get_transaction_id() ) {
3884
-			$this->set_transaction_id( $transaction_id );
3885
-		}
3883
+        if ( ! $this->get_transaction_id() ) {
3884
+            $this->set_transaction_id( $transaction_id );
3885
+        }
3886 3886
 
3887
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3888
-			return $this->save();
3889
-		}
3887
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3888
+            return $this->save();
3889
+        }
3890 3890
 
3891
-		// Set the completed date.
3892
-		$this->set_date_completed( current_time( 'mysql' ) );
3891
+        // Set the completed date.
3892
+        $this->set_date_completed( current_time( 'mysql' ) );
3893 3893
 
3894
-		// Set the new status.
3895
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3896
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3894
+        // Set the new status.
3895
+        $gateway = sanitize_text_field( $this->get_gateway_title() );
3896
+        if ( $this->is_renewal() || ! $this->is_parent() ) {
3897 3897
 
3898
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3899
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3898
+            $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3899
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3900 3900
 
3901
-			if ( 'none' == $this->get_gateway() ) {
3902
-				$_note = $note;
3903
-			}
3901
+            if ( 'none' == $this->get_gateway() ) {
3902
+                $_note = $note;
3903
+            }
3904 3904
 
3905
-			$this->set_status( 'wpi-renewal', $_note );
3905
+            $this->set_status( 'wpi-renewal', $_note );
3906 3906
 
3907
-		} else {
3907
+        } else {
3908 3908
 
3909
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3910
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3909
+            $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3910
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3911 3911
 
3912
-			if ( 'none' == $this->get_gateway() ) {
3913
-				$_note = $note;
3914
-			}
3912
+            if ( 'none' == $this->get_gateway() ) {
3913
+                $_note = $note;
3914
+            }
3915 3915
 
3916
-			$this->set_status( 'publish', $_note );
3916
+            $this->set_status( 'publish', $_note );
3917 3917
 
3918
-		}
3918
+        }
3919 3919
 
3920
-		// Set checkout mode.
3921
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3922
-		$this->set_mode( $mode );
3920
+        // Set checkout mode.
3921
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3922
+        $this->set_mode( $mode );
3923 3923
 
3924
-		// Save the invoice.
3924
+        // Save the invoice.
3925 3925
         $this->save();
3926
-	}
3927
-
3928
-	/**
3929
-	 * Save data to the database.
3930
-	 *
3931
-	 * @since 1.0.19
3932
-	 * @return int invoice ID
3933
-	 */
3934
-	public function save() {
3935
-		$this->maybe_set_date_paid();
3936
-		$this->maybe_set_key();
3937
-		parent::save();
3938
-		$this->clear_cache();
3939
-		$this->status_transition();
3940
-		return $this->get_id();
3941
-	}
3942
-
3943
-	/**
3926
+    }
3927
+
3928
+    /**
3929
+     * Save data to the database.
3930
+     *
3931
+     * @since 1.0.19
3932
+     * @return int invoice ID
3933
+     */
3934
+    public function save() {
3935
+        $this->maybe_set_date_paid();
3936
+        $this->maybe_set_key();
3937
+        parent::save();
3938
+        $this->clear_cache();
3939
+        $this->status_transition();
3940
+        return $this->get_id();
3941
+    }
3942
+
3943
+    /**
3944 3944
      * Clears the subscription's cache.
3945 3945
      */
3946 3946
     public function clear_cache() {
3947
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3948
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3949
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3950
-	}
3947
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3948
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3949
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3950
+    }
3951 3951
 
3952 3952
 }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 1 patch
Indentation   +575 added lines, -575 removed lines patch added patch discarded remove patch
@@ -14,90 +14,90 @@  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_send_invoice', array( $this, 'send_customer_invoice' ) );
66
-		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_send_invoice', array( $this, 'send_customer_invoice' ) );
66
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
67 67
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
75
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
76
-		do_action( 'getpaid_init_admin_hooks', $this );
77
-
78
-		// Setup/welcome
79
-		if ( ! empty( $_GET['page'] ) ) {
80
-			switch ( $_GET['page'] ) {
81
-				case 'gp-setup' :
82
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
83
-					break;
84
-			}
85
-		}
68
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
69
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
70
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
71
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
72
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
73
+        add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
74
+        add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
75
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
76
+        do_action( 'getpaid_init_admin_hooks', $this );
77
+
78
+        // Setup/welcome
79
+        if ( ! empty( $_GET['page'] ) ) {
80
+            switch ( $_GET['page'] ) {
81
+                case 'gp-setup' :
82
+                    include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
83
+                    break;
84
+            }
85
+        }
86 86
 
87 87
     }
88 88
 
89 89
     /**
90
-	 * Register admin scripts
91
-	 *
92
-	 */
93
-	public function enqeue_scripts() {
90
+     * Register admin scripts
91
+     *
92
+     */
93
+    public function enqeue_scripts() {
94 94
         global $current_screen, $pagenow;
95 95
 
96
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
97
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
96
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
97
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
98 98
 
99 99
         if ( ! empty( $current_screen->post_type ) ) {
100
-			$page = $current_screen->post_type;
100
+            $page = $current_screen->post_type;
101 101
         }
102 102
 
103 103
         // General styles.
@@ -118,54 +118,54 @@  discard block
 block discarded – undo
118 118
         }
119 119
 
120 120
         // Payment form scripts.
121
-		if ( 'wpi_payment_form' == $page && $editing ) {
121
+        if ( 'wpi_payment_form' == $page && $editing ) {
122 122
             $this->load_payment_form_scripts();
123 123
         }
124 124
 
125
-		if ( $page == 'wpinv-subscriptions' ) {
126
-			wp_enqueue_script( 'postbox' );
127
-		}
125
+        if ( $page == 'wpinv-subscriptions' ) {
126
+            wp_enqueue_script( 'postbox' );
127
+        }
128 128
 
129 129
     }
130 130
 
131 131
     /**
132
-	 * Returns admin js translations.
133
-	 *
134
-	 */
135
-	protected function get_admin_i18() {
132
+     * Returns admin js translations.
133
+     *
134
+     */
135
+    protected function get_admin_i18() {
136 136
         global $post;
137 137
 
138
-		$date_range = array(
139
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
140
-		);
138
+        $date_range = array(
139
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
140
+        );
141 141
 
142
-		if ( $date_range['period'] == 'custom' ) {
142
+        if ( $date_range['period'] == 'custom' ) {
143 143
 			
144
-			if ( isset( $_GET['from'] ) ) {
145
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
146
-			}
144
+            if ( isset( $_GET['from'] ) ) {
145
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
146
+            }
147 147
 
148
-			if ( isset( $_GET['to'] ) ) {
149
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
150
-			}
148
+            if ( isset( $_GET['to'] ) ) {
149
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
150
+            }
151 151
 
152
-		}
152
+        }
153 153
 
154 154
         $i18n = array(
155 155
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
156 156
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
157
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
158
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
159
-			'rest_root'                 => esc_url_raw( rest_url() ),
160
-			'date_range'                => $date_range,
157
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
158
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
159
+            'rest_root'                 => esc_url_raw( rest_url() ),
160
+            'date_range'                => $date_range,
161 161
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
162 162
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
163 163
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
164 164
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
165 165
             'tax'                       => wpinv_tax_amount(),
166 166
             'discount'                  => 0,
167
-			'currency_symbol'           => wpinv_currency_symbol(),
168
-			'currency'                  => wpinv_get_currency(),
167
+            'currency_symbol'           => wpinv_currency_symbol(),
168
+            'currency'                  => wpinv_get_currency(),
169 169
             'currency_pos'              => wpinv_currency_position(),
170 170
             'thousand_sep'              => wpinv_thousands_separator(),
171 171
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -185,118 +185,118 @@  discard block
 block discarded – undo
185 185
             'item_description'          => __( 'Item Description', 'invoicing' ),
186 186
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
187 187
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
188
-			'searching'                 => __( 'Searching', 'invoicing' ),
189
-			'loading'                   => __( 'Loading...', 'invoicing' ),
190
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
191
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
188
+            'searching'                 => __( 'Searching', 'invoicing' ),
189
+            'loading'                   => __( 'Loading...', 'invoicing' ),
190
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
191
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
192 192
         );
193 193
 
194
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
194
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
195 195
 
196
-			$invoice              = new WPInv_Invoice( $post );
197
-			$i18n['save_invoice'] = sprintf(
198
-				__( 'Save %s', 'invoicing' ),
199
-				ucfirst( $invoice->get_invoice_quote_type() )
200
-			);
196
+            $invoice              = new WPInv_Invoice( $post );
197
+            $i18n['save_invoice'] = sprintf(
198
+                __( 'Save %s', 'invoicing' ),
199
+                ucfirst( $invoice->get_invoice_quote_type() )
200
+            );
201 201
 
202
-			$i18n['invoice_description'] = sprintf(
203
-				__( '%s Description', 'invoicing' ),
204
-				ucfirst( $invoice->get_invoice_quote_type() )
205
-			);
202
+            $i18n['invoice_description'] = sprintf(
203
+                __( '%s Description', 'invoicing' ),
204
+                ucfirst( $invoice->get_invoice_quote_type() )
205
+            );
206 206
 
207
-		}
208
-		return $i18n;
209
-	}
207
+        }
208
+        return $i18n;
209
+    }
210 210
 
211
-	/**
212
-	 * Change the admin footer text on GetPaid admin pages.
213
-	 *
214
-	 * @since  2.0.0
215
-	 * @param  string $footer_text
216
-	 * @return string
217
-	 */
218
-	public function admin_footer_text( $footer_text ) {
219
-		global $current_screen;
211
+    /**
212
+     * Change the admin footer text on GetPaid admin pages.
213
+     *
214
+     * @since  2.0.0
215
+     * @param  string $footer_text
216
+     * @return string
217
+     */
218
+    public function admin_footer_text( $footer_text ) {
219
+        global $current_screen;
220 220
 
221
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
221
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
222 222
 
223 223
         if ( ! empty( $current_screen->post_type ) ) {
224
-			$page = $current_screen->post_type;
224
+            $page = $current_screen->post_type;
225 225
         }
226 226
 
227 227
         // General styles.
228 228
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
229 229
 
230
-			// Change the footer text
231
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
232
-
233
-				$rating_url  = esc_url(
234
-					wp_nonce_url(
235
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
236
-						'getpaid-nonce',
237
-						'getpaid-nonce'
238
-						)
239
-				);
240
-
241
-				$footer_text = sprintf(
242
-					/* translators: %s: five stars */
243
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
244
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
245
-				);
246
-
247
-			} else {
248
-
249
-				$footer_text = sprintf(
250
-					/* translators: %s: GetPaid */
251
-					__( 'Thank you for using %s!', 'invoicing' ),
252
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
253
-				);
254
-
255
-			}
256
-
257
-		}
258
-
259
-		return $footer_text;
260
-	}
261
-
262
-	/**
263
-	 * Redirects to wp.org to rate the plugin.
264
-	 *
265
-	 * @since  2.0.0
266
-	 */
267
-	public function redirect_to_wordpress_rating_page() {
268
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
269
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
270
-		exit;
271
-	}
272
-
273
-    /**
274
-	 * Loads payment form js.
275
-	 *
276
-	 */
277
-	protected function load_payment_form_scripts() {
230
+            // Change the footer text
231
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
232
+
233
+                $rating_url  = esc_url(
234
+                    wp_nonce_url(
235
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
236
+                        'getpaid-nonce',
237
+                        'getpaid-nonce'
238
+                        )
239
+                );
240
+
241
+                $footer_text = sprintf(
242
+                    /* translators: %s: five stars */
243
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
244
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
245
+                );
246
+
247
+            } else {
248
+
249
+                $footer_text = sprintf(
250
+                    /* translators: %s: GetPaid */
251
+                    __( 'Thank you for using %s!', 'invoicing' ),
252
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
253
+                );
254
+
255
+            }
256
+
257
+        }
258
+
259
+        return $footer_text;
260
+    }
261
+
262
+    /**
263
+     * Redirects to wp.org to rate the plugin.
264
+     *
265
+     * @since  2.0.0
266
+     */
267
+    public function redirect_to_wordpress_rating_page() {
268
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
269
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
270
+        exit;
271
+    }
272
+
273
+    /**
274
+     * Loads payment form js.
275
+     *
276
+     */
277
+    protected function load_payment_form_scripts() {
278 278
         global $post;
279 279
 
280 280
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
281
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
282
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
281
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
282
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
283 283
 
284
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
285
-		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 );
284
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
285
+        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 );
286 286
 
287
-		wp_localize_script(
287
+        wp_localize_script(
288 288
             'wpinv-admin-payment-form-script',
289 289
             'wpinvPaymentFormAdmin',
290 290
             array(
291
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
292
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
293
-				'currency'      => wpinv_currency_symbol(),
294
-				'position'      => wpinv_currency_position(),
295
-				'decimals'      => (int) wpinv_decimals(),
296
-				'thousands_sep' => wpinv_thousands_separator(),
297
-				'decimals_sep'  => wpinv_decimal_separator(),
298
-				'form_items'    => gepaid_get_form_items( $post->ID ),
299
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
291
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
292
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
293
+                'currency'      => wpinv_currency_symbol(),
294
+                'position'      => wpinv_currency_position(),
295
+                'decimals'      => (int) wpinv_decimals(),
296
+                'thousands_sep' => wpinv_thousands_separator(),
297
+                'decimals_sep'  => wpinv_decimal_separator(),
298
+                'form_items'    => gepaid_get_form_items( $post->ID ),
299
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
300 300
             )
301 301
         );
302 302
 
@@ -305,20 +305,20 @@  discard block
 block discarded – undo
305 305
     }
306 306
 
307 307
     /**
308
-	 * Add our classes to admin pages.
308
+     * Add our classes to admin pages.
309 309
      *
310 310
      * @param string $classes
311 311
      * @return string
312
-	 *
313
-	 */
312
+     *
313
+     */
314 314
     public function admin_body_class( $classes ) {
315
-		global $pagenow, $post, $current_screen;
315
+        global $pagenow, $post, $current_screen;
316 316
 
317 317
 
318 318
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
319 319
 
320 320
         if ( ! empty( $current_screen->post_type ) ) {
321
-			$page = $current_screen->post_type;
321
+            $page = $current_screen->post_type;
322 322
         }
323 323
 
324 324
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -327,68 +327,68 @@  discard block
 block discarded – undo
327 327
 
328 328
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
329 329
             $classes .= ' wpinv-cpt wpinv';
330
-		}
330
+        }
331 331
 		
332
-		if ( getpaid_is_invoice_post_type( $page ) ) {
332
+        if ( getpaid_is_invoice_post_type( $page ) ) {
333 333
             $classes .= ' getpaid-is-invoice-cpt';
334 334
         }
335 335
 
336
-		return $classes;
336
+        return $classes;
337 337
     }
338 338
 
339 339
     /**
340
-	 * Maybe show the AyeCode Connect Notice.
341
-	 */
342
-	public function init_ayecode_connect_helper(){
340
+     * Maybe show the AyeCode Connect Notice.
341
+     */
342
+    public function init_ayecode_connect_helper(){
343 343
 
344
-		// Register with the deactivation survey class.
345
-		AyeCode_Deactivation_Survey::instance(array(
346
-			'slug'		        => 'invoicing',
347
-			'version'	        => WPINV_VERSION,
348
-			'support_url'       => 'https://wpgetpaid.com/support/',
349
-			'documentation_url' => 'https://docs.wpgetpaid.com/',
350
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
351
-		));
344
+        // Register with the deactivation survey class.
345
+        AyeCode_Deactivation_Survey::instance(array(
346
+            'slug'		        => 'invoicing',
347
+            'version'	        => WPINV_VERSION,
348
+            'support_url'       => 'https://wpgetpaid.com/support/',
349
+            'documentation_url' => 'https://docs.wpgetpaid.com/',
350
+            'activated'         => (int) get_option( 'gepaid_installed_on' ),
351
+        ));
352 352
 
353 353
         new AyeCode_Connect_Helper(
354 354
             array(
355
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
356
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
357
-				'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>" ),
358
-				'connect_button'    => __("Connect Site","invoicing"),
359
-				'connecting_button'    => __("Connecting...","invoicing"),
360
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
361
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
355
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
356
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
357
+                '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>" ),
358
+                'connect_button'    => __("Connect Site","invoicing"),
359
+                'connecting_button'    => __("Connecting...","invoicing"),
360
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
361
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
362 362
             ),
363 363
             array( 'wpi-addons' )
364 364
         );
365 365
 
366 366
     }
367 367
 
368
-	/**
369
-	 * Redirect users to settings on activation.
370
-	 *
371
-	 * @return void
372
-	 */
373
-	public function activation_redirect() {
368
+    /**
369
+     * Redirect users to settings on activation.
370
+     *
371
+     * @return void
372
+     */
373
+    public function activation_redirect() {
374 374
 
375
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
375
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
376 376
 
377
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
378
-			return;
379
-		}
377
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
378
+            return;
379
+        }
380 380
 
381
-		// Bail if activating from network, or bulk
382
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
383
-			return;
384
-		}
381
+        // Bail if activating from network, or bulk
382
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
383
+            return;
384
+        }
385 385
 
386
-	    update_option( 'wpinv_redirected_to_settings', 1 );
386
+        update_option( 'wpinv_redirected_to_settings', 1 );
387 387
 
388 388
         wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
389 389
         exit;
390 390
 
391
-	}
391
+    }
392 392
 
393 393
     /**
394 394
      * Fires an admin action after verifying that a user can fire them.
@@ -402,498 +402,498 @@  discard block
 block discarded – undo
402 402
 
403 403
     }
404 404
 
405
-	/**
405
+    /**
406 406
      * Sends a payment reminder to a customer.
407
-	 * 
408
-	 * @param array $args
407
+     * 
408
+     * @param array $args
409 409
      */
410 410
     public function duplicate_payment_form( $args ) {
411 411
 
412
-		if ( empty( $args['form_id'] ) ) {
413
-			return;
414
-		}
415
-
416
-		$form = new GetPaid_Payment_Form( $args['form_id'] );
412
+        if ( empty( $args['form_id'] ) ) {
413
+            return;
414
+        }
417 415
 
418
-		if ( ! $form->exists() ) {
419
-			return;
420
-		}
416
+        $form = new GetPaid_Payment_Form( $args['form_id'] );
421 417
 
422
-		$new_form = new GetPaid_Payment_Form();
423
-		$new_form->set_author( $form->get_author( 'edit' ) );
424
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
425
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
426
-		$new_form->set_items( $form->get_items( 'edit' ) );
427
-		$new_form->save();
418
+        if ( ! $form->exists() ) {
419
+            return;
420
+        }
428 421
 
429
-		if ( $new_form->exists() ) {
430
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
431
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
432
-		} else {
433
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
434
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
435
-		}
422
+        $new_form = new GetPaid_Payment_Form();
423
+        $new_form->set_author( $form->get_author( 'edit' ) );
424
+        $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
425
+        $new_form->set_elements( $form->get_elements( 'edit' ) );
426
+        $new_form->set_items( $form->get_items( 'edit' ) );
427
+        $new_form->save();
428
+
429
+        if ( $new_form->exists() ) {
430
+            $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
431
+            $url = get_edit_post_link( $new_form->get_id(), 'edit' );
432
+        } else {
433
+            $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
434
+            $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
435
+        }
436 436
 
437
-		wp_redirect( $url );
438
-		exit;
439
-	}
437
+        wp_redirect( $url );
438
+        exit;
439
+    }
440 440
 
441
-	/**
441
+    /**
442 442
      * Sends a payment reminder to a customer.
443
-	 * 
444
-	 * @param array $args
443
+     * 
444
+     * @param array $args
445 445
      */
446 446
     public function send_customer_invoice( $args ) {
447
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
447
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
448 448
 
449
-		if ( $sent ) {
450
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
451
-		} else {
452
-			$this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
453
-		}
449
+        if ( $sent ) {
450
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
451
+        } else {
452
+            $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
453
+        }
454 454
 
455
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
456
-		exit;
457
-	}
455
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
456
+        exit;
457
+    }
458 458
 
459
-	/**
459
+    /**
460 460
      * Sends a payment reminder to a customer.
461
-	 * 
462
-	 * @param array $args
461
+     * 
462
+     * @param array $args
463 463
      */
464 464
     public function send_customer_payment_reminder( $args ) {
465
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
465
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
466 466
 
467
-		if ( $sent ) {
468
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
469
-		} else {
470
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
471
-		}
467
+        if ( $sent ) {
468
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
469
+        } else {
470
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
471
+        }
472 472
 
473
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
474
-		exit;
475
-	}
473
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
474
+        exit;
475
+    }
476 476
 
477
-	/**
477
+    /**
478 478
      * Resets tax rates.
479
-	 * 
479
+     * 
480 480
      */
481 481
     public function admin_reset_tax_rates() {
482 482
 
483
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
484
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
485
-		exit;
483
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
484
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
485
+        exit;
486 486
 
487
-	}
487
+    }
488 488
 
489
-	/**
489
+    /**
490 490
      * Resets admin pages.
491
-	 * 
491
+     * 
492 492
      */
493 493
     public function admin_create_missing_pages() {
494
-		$installer = new GetPaid_Installer();
495
-		$installer->create_pages();
496
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
497
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
498
-		exit;
499
-	}
500
-
501
-	/**
494
+        $installer = new GetPaid_Installer();
495
+        $installer->create_pages();
496
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
497
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
498
+        exit;
499
+    }
500
+
501
+    /**
502 502
      * Creates an missing admin tables.
503
-	 * 
503
+     * 
504 504
      */
505 505
     public function admin_create_missing_tables() {
506
-		global $wpdb;
507
-		$installer = new GetPaid_Installer();
506
+        global $wpdb;
507
+        $installer = new GetPaid_Installer();
508 508
 
509
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
510
-			$installer->create_subscriptions_table();
509
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
510
+            $installer->create_subscriptions_table();
511 511
 
512
-			if ( $wpdb->last_error !== '' ) {
513
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
514
-			}
515
-		}
512
+            if ( $wpdb->last_error !== '' ) {
513
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
514
+            }
515
+        }
516 516
 
517
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
518
-			$installer->create_invoices_table();
517
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
518
+            $installer->create_invoices_table();
519 519
 
520
-			if ( $wpdb->last_error !== '' ) {
521
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
522
-			}
523
-		}
520
+            if ( $wpdb->last_error !== '' ) {
521
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
522
+            }
523
+        }
524 524
 
525
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
526
-			$installer->create_invoice_items_table();
525
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
526
+            $installer->create_invoice_items_table();
527 527
 
528
-			if ( $wpdb->last_error !== '' ) {
529
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
530
-			}
531
-		}
528
+            if ( $wpdb->last_error !== '' ) {
529
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
530
+            }
531
+        }
532 532
 
533
-		if ( ! $this->has_notices() ) {
534
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
535
-		}
533
+        if ( ! $this->has_notices() ) {
534
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
535
+        }
536 536
 
537
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
538
-		exit;
539
-	}
537
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
538
+        exit;
539
+    }
540 540
 
541
-	/**
541
+    /**
542 542
      * Migrates old invoices to the new database tables.
543
-	 * 
543
+     * 
544 544
      */
545 545
     public function admin_migrate_old_invoices() {
546 546
 
547
-		// Migrate the invoices.
548
-		$installer = new GetPaid_Installer();
549
-		$installer->migrate_old_invoices();
547
+        // Migrate the invoices.
548
+        $installer = new GetPaid_Installer();
549
+        $installer->migrate_old_invoices();
550 550
 
551
-		// Show an admin message.
552
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
551
+        // Show an admin message.
552
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
553 553
 
554
-		// Redirect the admin.
555
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
556
-		exit;
554
+        // Redirect the admin.
555
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
556
+        exit;
557 557
 
558
-	}
558
+    }
559 559
 
560
-	/**
560
+    /**
561 561
      * Download customers.
562
-	 * 
562
+     * 
563 563
      */
564 564
     public function admin_download_customers() {
565
-		global $wpdb;
565
+        global $wpdb;
566 566
 
567
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
567
+        $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
568 568
 
569
-		header( "Content-Type:text/csv" );
570
-		header( "Content-Disposition:attachment;filename=customers.csv" );
569
+        header( "Content-Type:text/csv" );
570
+        header( "Content-Disposition:attachment;filename=customers.csv" );
571 571
 
572
-		$post_types = '';
572
+        $post_types = '';
573 573
 
574
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
575
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
576
-		}
574
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
575
+            $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
576
+        }
577 577
 
578
-		$post_types = rtrim( $post_types, ' OR' );
578
+        $post_types = rtrim( $post_types, ' OR' );
579 579
 
580
-		$customers = $wpdb->get_col(
581
-			$wpdb->prepare(
582
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
583
-			)
584
-		);
580
+        $customers = $wpdb->get_col(
581
+            $wpdb->prepare(
582
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
583
+            )
584
+        );
585 585
 
586
-		$columns = array(
587
-			'name'     => __( 'Name', 'invoicing' ),
588
-			'email'    => __( 'Email', 'invoicing' ),
589
-			'country'  => __( 'Country', 'invoicing' ),
590
-			'state'    => __( 'State', 'invoicing' ),
591
-			'city'     => __( 'City', 'invoicing' ),
592
-			'zip'      => __( 'ZIP', 'invoicing' ),
593
-			'address'  => __( 'Address', 'invoicing' ),
594
-			'phone'    => __( 'Phone', 'invoicing' ),
595
-			'company'  => __( 'Company', 'invoicing' ),
596
-			'company_id'  => __( 'Company ID', 'invoicing' ),
597
-			'invoices' => __( 'Invoices', 'invoicing' ),
598
-			'total_raw' => __( 'Total Spend', 'invoicing' ),
599
-			'signup'   => __( 'Date created', 'invoicing' ),
600
-		);
586
+        $columns = array(
587
+            'name'     => __( 'Name', 'invoicing' ),
588
+            'email'    => __( 'Email', 'invoicing' ),
589
+            'country'  => __( 'Country', 'invoicing' ),
590
+            'state'    => __( 'State', 'invoicing' ),
591
+            'city'     => __( 'City', 'invoicing' ),
592
+            'zip'      => __( 'ZIP', 'invoicing' ),
593
+            'address'  => __( 'Address', 'invoicing' ),
594
+            'phone'    => __( 'Phone', 'invoicing' ),
595
+            'company'  => __( 'Company', 'invoicing' ),
596
+            'company_id'  => __( 'Company ID', 'invoicing' ),
597
+            'invoices' => __( 'Invoices', 'invoicing' ),
598
+            'total_raw' => __( 'Total Spend', 'invoicing' ),
599
+            'signup'   => __( 'Date created', 'invoicing' ),
600
+        );
601 601
 
602
-		// Output the csv column headers.
603
-		fputcsv( $output, array_values( $columns ) );
602
+        // Output the csv column headers.
603
+        fputcsv( $output, array_values( $columns ) );
604 604
 
605
-		// Loop through
606
-		$table = new WPInv_Customers_Table();
607
-		foreach ( $customers as $customer_id ) {
605
+        // Loop through
606
+        $table = new WPInv_Customers_Table();
607
+        foreach ( $customers as $customer_id ) {
608 608
 
609
-			$user = get_user_by( 'id', $customer_id );
610
-			$row  = array();
611
-			if ( empty( $user ) ) {
612
-				continue;
613
-			}
609
+            $user = get_user_by( 'id', $customer_id );
610
+            $row  = array();
611
+            if ( empty( $user ) ) {
612
+                continue;
613
+            }
614 614
 
615
-			foreach ( array_keys( $columns ) as $column ) {
615
+            foreach ( array_keys( $columns ) as $column ) {
616 616
 
617
-				$method = 'column_' . $column;
617
+                $method = 'column_' . $column;
618 618
 
619
-				if ( 'name' == $column ) {
620
-					$value = esc_html( $user->display_name );
621
-				} else if( 'email' == $column ) {
622
-					$value = sanitize_email( $user->user_email );
623
-				} else if ( is_callable( array( $table, $method ) ) ) {
624
-					$value = strip_tags( $table->$method( $user ) );
625
-				}
619
+                if ( 'name' == $column ) {
620
+                    $value = esc_html( $user->display_name );
621
+                } else if( 'email' == $column ) {
622
+                    $value = sanitize_email( $user->user_email );
623
+                } else if ( is_callable( array( $table, $method ) ) ) {
624
+                    $value = strip_tags( $table->$method( $user ) );
625
+                }
626 626
 
627
-				if ( empty( $value ) ) {
628
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
629
-				}
627
+                if ( empty( $value ) ) {
628
+                    $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
629
+                }
630 630
 
631
-				$row[] = $value;
631
+                $row[] = $value;
632 632
 
633
-			}
633
+            }
634 634
 
635
-			fputcsv( $output, $row );
636
-		}
635
+            fputcsv( $output, $row );
636
+        }
637 637
 
638
-		fclose( $output );
639
-		exit;
638
+        fclose( $output );
639
+        exit;
640 640
 
641
-	}
641
+    }
642 642
 
643
-	/**
643
+    /**
644 644
      * Installs a plugin.
645
-	 *
646
-	 * @param array $data
645
+     *
646
+     * @param array $data
647 647
      */
648 648
     public function admin_install_plugin( $data ) {
649 649
 
650
-		if ( ! empty( $data['plugins'] ) ) {
651
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
652
-			wp_cache_flush();
650
+        if ( ! empty( $data['plugins'] ) ) {
651
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
652
+            wp_cache_flush();
653 653
 
654
-			foreach ( $data['plugins'] as $slug => $file ) {
655
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
656
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
657
-				$installed  = $upgrader->install( $plugin_zip );
654
+            foreach ( $data['plugins'] as $slug => $file ) {
655
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
656
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
657
+                $installed  = $upgrader->install( $plugin_zip );
658 658
 
659
-				if ( ! is_wp_error( $installed ) && $installed ) {
660
-					activate_plugin( $file, '', false, true );
661
-				} else {
662
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
663
-				}
659
+                if ( ! is_wp_error( $installed ) && $installed ) {
660
+                    activate_plugin( $file, '', false, true );
661
+                } else {
662
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
663
+                }
664 664
 
665
-			}
665
+            }
666 666
 
667
-		}
667
+        }
668 668
 
669
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
670
-		wp_safe_redirect( $redirect );
671
-		exit;
669
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
670
+        wp_safe_redirect( $redirect );
671
+        exit;
672 672
 
673
-	}
673
+    }
674 674
 
675
-	/**
675
+    /**
676 676
      * Connects a gateway.
677
-	 *
678
-	 * @param array $data
677
+     *
678
+     * @param array $data
679 679
      */
680 680
     public function admin_connect_gateway( $data ) {
681 681
 
682
-		if ( ! empty( $data['plugin'] ) ) {
682
+        if ( ! empty( $data['plugin'] ) ) {
683 683
 
684
-			$gateway     = sanitize_key( $data['plugin'] );
685
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
684
+            $gateway     = sanitize_key( $data['plugin'] );
685
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
686 686
 
687
-			if ( ! empty( $connect_url ) ) {
688
-				wp_redirect( $connect_url );
689
-				exit;
690
-			}
687
+            if ( ! empty( $connect_url ) ) {
688
+                wp_redirect( $connect_url );
689
+                exit;
690
+            }
691 691
 
692
-			if ( 'stripe' == $data['plugin'] ) {
693
-				require_once ABSPATH . 'wp-admin/includes/plugin.php';
694
-				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
695
-				wp_cache_flush();
692
+            if ( 'stripe' == $data['plugin'] ) {
693
+                require_once ABSPATH . 'wp-admin/includes/plugin.php';
694
+                include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
695
+                wp_cache_flush();
696 696
 
697
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
698
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
699
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
700
-					$upgrader->install( $plugin_zip );
701
-				}
697
+                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
698
+                    $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
699
+                    $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
700
+                    $upgrader->install( $plugin_zip );
701
+                }
702 702
 
703
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
704
-			}
703
+                activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
704
+            }
705 705
 
706
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
707
-			if ( ! empty( $connect_url ) ) {
708
-				wp_redirect( $connect_url );
709
-				exit;
710
-			}
706
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
707
+            if ( ! empty( $connect_url ) ) {
708
+                wp_redirect( $connect_url );
709
+                exit;
710
+            }
711 711
 
712
-		}
712
+        }
713 713
 
714
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
715
-		wp_safe_redirect( $redirect );
716
-		exit;
714
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
715
+        wp_safe_redirect( $redirect );
716
+        exit;
717 717
 
718
-	}
718
+    }
719 719
 
720
-	/**
720
+    /**
721 721
      * Recalculates discounts.
722
-	 * 
722
+     * 
723 723
      */
724 724
     public function admin_recalculate_discounts() {
725
-		global $wpdb;
725
+        global $wpdb;
726 726
 
727
-		// Fetch all invoices that have discount codes.
728
-		$table    = $wpdb->prefix . 'getpaid_invoices';
729
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
727
+        // Fetch all invoices that have discount codes.
728
+        $table    = $wpdb->prefix . 'getpaid_invoices';
729
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
730 730
 
731
-		foreach ( $invoices as $invoice ) {
731
+        foreach ( $invoices as $invoice ) {
732 732
 
733
-			$invoice = new WPInv_Invoice( $invoice );
733
+            $invoice = new WPInv_Invoice( $invoice );
734 734
 
735
-			if ( ! $invoice->exists() ) {
736
-				continue;
737
-			}
735
+            if ( ! $invoice->exists() ) {
736
+                continue;
737
+            }
738 738
 
739
-			// Abort if the discount does not exist or does not apply here.
740
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
741
-			if ( ! $discount->exists() ) {
742
-				continue;
743
-			}
739
+            // Abort if the discount does not exist or does not apply here.
740
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
741
+            if ( ! $discount->exists() ) {
742
+                continue;
743
+            }
744 744
 
745
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
746
-			$invoice->recalculate_total();
745
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
746
+            $invoice->recalculate_total();
747 747
 
748
-			if ( $invoice->get_total_discount() > 0 ) {
749
-				$invoice->save();
750
-			}
748
+            if ( $invoice->get_total_discount() > 0 ) {
749
+                $invoice->save();
750
+            }
751 751
 
752
-		}
752
+        }
753 753
 
754
-		// Show an admin message.
755
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
754
+        // Show an admin message.
755
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
756 756
 
757
-		// Redirect the admin.
758
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
759
-		exit;
757
+        // Redirect the admin.
758
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
759
+        exit;
760 760
 
761
-	}
761
+    }
762 762
 
763 763
     /**
764
-	 * Returns an array of admin notices.
765
-	 *
766
-	 * @since       1.0.19
764
+     * Returns an array of admin notices.
765
+     *
766
+     * @since       1.0.19
767 767
      * @return array
768
-	 */
769
-	public function get_notices() {
770
-		$notices = get_option( 'wpinv_admin_notices' );
768
+     */
769
+    public function get_notices() {
770
+        $notices = get_option( 'wpinv_admin_notices' );
771 771
         return is_array( $notices ) ? $notices : array();
772
-	}
772
+    }
773 773
 
774
-	/**
775
-	 * Checks if we have any admin notices.
776
-	 *
777
-	 * @since       2.0.4
774
+    /**
775
+     * Checks if we have any admin notices.
776
+     *
777
+     * @since       2.0.4
778 778
      * @return array
779
-	 */
780
-	public function has_notices() {
781
-		return count( $this->get_notices() ) > 0;
782
-	}
783
-
784
-	/**
785
-	 * Clears all admin notices
786
-	 *
787
-	 * @access      public
788
-	 * @since       1.0.19
789
-	 */
790
-	public function clear_notices() {
791
-		delete_option( 'wpinv_admin_notices' );
792
-	}
793
-
794
-	/**
795
-	 * Saves a new admin notice
796
-	 *
797
-	 * @access      public
798
-	 * @since       1.0.19
799
-	 */
800
-	public function save_notice( $type, $message ) {
801
-		$notices = $this->get_notices();
802
-
803
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
804
-			$notices[ $type ] = array();
805
-		}
806
-
807
-		$notices[ $type ][] = $message;
808
-
809
-		update_option( 'wpinv_admin_notices', $notices );
810
-	}
811
-
812
-	/**
813
-	 * Displays a success notice
814
-	 *
815
-	 * @param       string $msg The message to qeue.
816
-	 * @access      public
817
-	 * @since       1.0.19
818
-	 */
819
-	public function show_success( $msg ) {
820
-		$this->save_notice( 'success', $msg );
821
-	}
822
-
823
-	/**
824
-	 * Displays a error notice
825
-	 *
826
-	 * @access      public
827
-	 * @param       string $msg The message to qeue.
828
-	 * @since       1.0.19
829
-	 */
830
-	public function show_error( $msg ) {
831
-		$this->save_notice( 'error', $msg );
832
-	}
833
-
834
-	/**
835
-	 * Displays a warning notice
836
-	 *
837
-	 * @access      public
838
-	 * @param       string $msg The message to qeue.
839
-	 * @since       1.0.19
840
-	 */
841
-	public function show_warning( $msg ) {
842
-		$this->save_notice( 'warning', $msg );
843
-	}
844
-
845
-	/**
846
-	 * Displays a info notice
847
-	 *
848
-	 * @access      public
849
-	 * @param       string $msg The message to qeue.
850
-	 * @since       1.0.19
851
-	 */
852
-	public function show_info( $msg ) {
853
-		$this->save_notice( 'info', $msg );
854
-	}
855
-
856
-	/**
857
-	 * Show notices
858
-	 *
859
-	 * @access      public
860
-	 * @since       1.0.19
861
-	 */
862
-	public function show_notices() {
779
+     */
780
+    public function has_notices() {
781
+        return count( $this->get_notices() ) > 0;
782
+    }
783
+
784
+    /**
785
+     * Clears all admin notices
786
+     *
787
+     * @access      public
788
+     * @since       1.0.19
789
+     */
790
+    public function clear_notices() {
791
+        delete_option( 'wpinv_admin_notices' );
792
+    }
793
+
794
+    /**
795
+     * Saves a new admin notice
796
+     *
797
+     * @access      public
798
+     * @since       1.0.19
799
+     */
800
+    public function save_notice( $type, $message ) {
801
+        $notices = $this->get_notices();
802
+
803
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
804
+            $notices[ $type ] = array();
805
+        }
806
+
807
+        $notices[ $type ][] = $message;
808
+
809
+        update_option( 'wpinv_admin_notices', $notices );
810
+    }
811
+
812
+    /**
813
+     * Displays a success notice
814
+     *
815
+     * @param       string $msg The message to qeue.
816
+     * @access      public
817
+     * @since       1.0.19
818
+     */
819
+    public function show_success( $msg ) {
820
+        $this->save_notice( 'success', $msg );
821
+    }
822
+
823
+    /**
824
+     * Displays a error notice
825
+     *
826
+     * @access      public
827
+     * @param       string $msg The message to qeue.
828
+     * @since       1.0.19
829
+     */
830
+    public function show_error( $msg ) {
831
+        $this->save_notice( 'error', $msg );
832
+    }
833
+
834
+    /**
835
+     * Displays a warning notice
836
+     *
837
+     * @access      public
838
+     * @param       string $msg The message to qeue.
839
+     * @since       1.0.19
840
+     */
841
+    public function show_warning( $msg ) {
842
+        $this->save_notice( 'warning', $msg );
843
+    }
844
+
845
+    /**
846
+     * Displays a info notice
847
+     *
848
+     * @access      public
849
+     * @param       string $msg The message to qeue.
850
+     * @since       1.0.19
851
+     */
852
+    public function show_info( $msg ) {
853
+        $this->save_notice( 'info', $msg );
854
+    }
855
+
856
+    /**
857
+     * Show notices
858
+     *
859
+     * @access      public
860
+     * @since       1.0.19
861
+     */
862
+    public function show_notices() {
863 863
 
864 864
         $notices = $this->get_notices();
865 865
         $this->clear_notices();
866 866
 
867
-		foreach ( $notices as $type => $messages ) {
867
+        foreach ( $notices as $type => $messages ) {
868 868
 
869
-			if ( ! is_array( $messages ) ) {
870
-				continue;
871
-			}
869
+            if ( ! is_array( $messages ) ) {
870
+                continue;
871
+            }
872 872
 
873 873
             $type  = sanitize_key( $type );
874
-			foreach ( $messages as $message ) {
874
+            foreach ( $messages as $message ) {
875 875
                 $message = wp_kses_post( $message );
876
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
876
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
877 877
             }
878 878
 
879 879
         }
880 880
 
881
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
882
-
883
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
884
-				$url     = wp_nonce_url(
885
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
886
-					'getpaid-nonce',
887
-					'getpaid-nonce'
888
-				);
889
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
890
-				$message2 = __( 'Generate Pages', 'invoicing' );
891
-				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
892
-				break;
893
-			}
881
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
882
+
883
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
884
+                $url     = wp_nonce_url(
885
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
886
+                    'getpaid-nonce',
887
+                    'getpaid-nonce'
888
+                );
889
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
890
+                $message2 = __( 'Generate Pages', 'invoicing' );
891
+                echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
892
+                break;
893
+            }
894 894
 
895
-		}
895
+        }
896 896
 
897
-	}
897
+    }
898 898
 
899 899
 }
Please login to merge, or discard this patch.
vendor/ayecode/wp-deactivation-survey/wp-deactivation-survey.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -1,103 +1,103 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit;
4
+    exit;
5 5
 }
6 6
 
7 7
 if ( ! class_exists( 'AyeCode_Deactivation_Survey' ) ) {
8 8
 
9
-	class AyeCode_Deactivation_Survey {
9
+    class AyeCode_Deactivation_Survey {
10 10
 
11
-		/**
12
-		 * AyeCode_Deactivation_Survey instance.
13
-		 *
14
-		 * @access private
15
-		 * @since  1.0.0
16
-		 * @var    AyeCode_Deactivation_Survey There can be only one!
17
-		 */
18
-		private static $instance = null;
11
+        /**
12
+         * AyeCode_Deactivation_Survey instance.
13
+         *
14
+         * @access private
15
+         * @since  1.0.0
16
+         * @var    AyeCode_Deactivation_Survey There can be only one!
17
+         */
18
+        private static $instance = null;
19 19
 
20
-		public static $plugins;
20
+        public static $plugins;
21 21
 
22
-		public $version = "1.0.4";
22
+        public $version = "1.0.4";
23 23
 
24
-		public static function instance( $plugin = array() ) {
25
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
-				self::$instance = new AyeCode_Deactivation_Survey;
27
-				self::$plugins = array();
24
+        public static function instance( $plugin = array() ) {
25
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_Deactivation_Survey ) ) {
26
+                self::$instance = new AyeCode_Deactivation_Survey;
27
+                self::$plugins = array();
28 28
 
29
-				add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
29
+                add_action( 'admin_enqueue_scripts', array( self::$instance, 'scripts' ) );
30 30
 
31
-				do_action( 'ayecode_deactivation_survey_loaded' );
32
-			}
31
+                do_action( 'ayecode_deactivation_survey_loaded' );
32
+            }
33 33
 
34
-			if(!empty($plugin)){
35
-				self::$plugins[] = (object)$plugin;
36
-			}
34
+            if(!empty($plugin)){
35
+                self::$plugins[] = (object)$plugin;
36
+            }
37 37
 
38
-			return self::$instance;
39
-		}
38
+            return self::$instance;
39
+        }
40 40
 
41
-		public function scripts() {
42
-			global $pagenow;
41
+        public function scripts() {
42
+            global $pagenow;
43 43
 
44
-			// Bail if we are not on the plugins page
45
-			if ( $pagenow != "plugins.php" ) {
46
-				return;
47
-			}
44
+            // Bail if we are not on the plugins page
45
+            if ( $pagenow != "plugins.php" ) {
46
+                return;
47
+            }
48 48
 
49
-			// Enqueue scripts
50
-			add_thickbox();
51
-			wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
49
+            // Enqueue scripts
50
+            add_thickbox();
51
+            wp_enqueue_script('ayecode-deactivation-survey', plugin_dir_url(__FILE__) . 'ayecode-ds.js');
52 52
 
53
-			/*
53
+            /*
54 54
 			 * Localized strings. Strings can be localised by plugins using this class.
55 55
 			 * We deliberately don't add textdomains here so that double textdomain warning is not given in theme review.
56 56
 			 */
57
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
-				'quick_feedback'			=> 'Quick Feedback',
59
-				'foreword'					=> 'If you would be kind enough, please tell us why you\'re deactivating?',
60
-				'better_plugins_name'		=> 'Please tell us which plugin?',
61
-				'please_tell_us'			=> 'Please tell us the reason so we can improve the plugin',
62
-				'do_not_attach_email'		=> 'Do not send my e-mail address with this feedback',
63
-				'brief_description'			=> 'Please give us any feedback that could help us improve',
64
-				'cancel'					=> 'Cancel',
65
-				'skip_and_deactivate'		=> 'Skip &amp; Deactivate',
66
-				'submit_and_deactivate'		=> 'Submit &amp; Deactivate',
67
-				'please_wait'				=> 'Please wait',
68
-				'get_support'				=> 'Get Support',
69
-				'documentation'				=> 'Documentation',
70
-				'thank_you'					=> 'Thank you!',
71
-			));
72
-
73
-			// Plugins
74
-			$plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
-
76
-			// Reasons
77
-			$defaultReasons = array(
78
-				'suddenly-stopped-working'	=> 'The plugin suddenly stopped working',
79
-				'plugin-broke-site'			=> 'The plugin broke my site',
80
-				'plugin-setup-difficult'	=> 'Too difficult to setup',
81
-				'plugin-design-difficult'	=> 'Too difficult to get the design i want',
82
-				'no-longer-needed'			=> 'I don\'t need this plugin any more',
83
-				'found-better-plugin'		=> 'I found a better plugin',
84
-				'temporary-deactivation'	=> 'It\'s a temporary deactivation, I\'m troubleshooting',
85
-				'other'						=> 'Other',
86
-			);
87
-
88
-			foreach($plugins as $plugin)
89
-			{
90
-				$plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
91
-				$plugin->url = home_url();
92
-				$plugin->activated = 0;
93
-			}
94
-
95
-			// Send plugin data
96
-			wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
97
-
98
-		}
57
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_strings', array(
58
+                'quick_feedback'			=> 'Quick Feedback',
59
+                'foreword'					=> 'If you would be kind enough, please tell us why you\'re deactivating?',
60
+                'better_plugins_name'		=> 'Please tell us which plugin?',
61
+                'please_tell_us'			=> 'Please tell us the reason so we can improve the plugin',
62
+                'do_not_attach_email'		=> 'Do not send my e-mail address with this feedback',
63
+                'brief_description'			=> 'Please give us any feedback that could help us improve',
64
+                'cancel'					=> 'Cancel',
65
+                'skip_and_deactivate'		=> 'Skip &amp; Deactivate',
66
+                'submit_and_deactivate'		=> 'Submit &amp; Deactivate',
67
+                'please_wait'				=> 'Please wait',
68
+                'get_support'				=> 'Get Support',
69
+                'documentation'				=> 'Documentation',
70
+                'thank_you'					=> 'Thank you!',
71
+            ));
72
+
73
+            // Plugins
74
+            $plugins = apply_filters('ayecode_deactivation_survey_plugins', self::$plugins);
75
+
76
+            // Reasons
77
+            $defaultReasons = array(
78
+                'suddenly-stopped-working'	=> 'The plugin suddenly stopped working',
79
+                'plugin-broke-site'			=> 'The plugin broke my site',
80
+                'plugin-setup-difficult'	=> 'Too difficult to setup',
81
+                'plugin-design-difficult'	=> 'Too difficult to get the design i want',
82
+                'no-longer-needed'			=> 'I don\'t need this plugin any more',
83
+                'found-better-plugin'		=> 'I found a better plugin',
84
+                'temporary-deactivation'	=> 'It\'s a temporary deactivation, I\'m troubleshooting',
85
+                'other'						=> 'Other',
86
+            );
87
+
88
+            foreach($plugins as $plugin)
89
+            {
90
+                $plugin->reasons = apply_filters('ayecode_deactivation_survey_reasons', $defaultReasons, $plugin);
91
+                $plugin->url = home_url();
92
+                $plugin->activated = 0;
93
+            }
94
+
95
+            // Send plugin data
96
+            wp_localize_script('ayecode-deactivation-survey', 'ayecodeds_deactivate_feedback_form_plugins', $plugins);
97
+
98
+        }
99 99
 		
100 100
 
101
-	}
101
+    }
102 102
 
103 103
 }
104 104
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/composer/InstalledVersions.php 1 patch
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' => '5d7aff0386ccd7f07945582811c9666af7b9e11a',
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' => '5d7aff0386ccd7f07945582811c9666af7b9e11a',
38
+        'pretty_version' => 'dev-master',
39
+        'version' => 'dev-master',
40
+        'aliases' => 
41
+        array (
42
+        ),
43
+        'reference' => '5d7aff0386ccd7f07945582811c9666af7b9e11a',
44 44
     ),
45 45
     'ayecode/wp-ayecode-ui' => 
46 46
     array (
47
-      'pretty_version' => '0.1.61',
48
-      'version' => '0.1.61.0',
49
-      'aliases' => 
50
-      array (
51
-      ),
52
-      'reference' => 'e97d1e520d6722df2cb323c04a6e818b1e901ab5',
47
+        'pretty_version' => '0.1.61',
48
+        'version' => '0.1.61.0',
49
+        'aliases' => 
50
+        array (
51
+        ),
52
+        'reference' => 'e97d1e520d6722df2cb323c04a6e818b1e901ab5',
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.27',
75
-      'version' => '1.0.27.0',
76
-      'aliases' => 
77
-      array (
78
-      ),
79
-      'reference' => 'ce187bc9afc5cd7f5d790d84eb6fd9b98e56992d',
74
+        'pretty_version' => '1.0.27',
75
+        'version' => '1.0.27.0',
76
+        'aliases' => 
77
+        array (
78
+        ),
79
+        'reference' => 'ce187bc9afc5cd7f5d790d84eb6fd9b98e56992d',
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.