Passed
Push — master ( f1dc5d...ba4e78 )
by Brian
05:10
created
templates/payment-forms/cart-item.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -24,64 +24,64 @@  discard block
 block discarded – undo
24 24
 
25 25
 				<?php
26 26
 
27
-					// Fires before printing a line item column.
28
-					do_action( "getpaid_form_cart_item_before_$key", $item, $form );
27
+                    // Fires before printing a line item column.
28
+                    do_action( "getpaid_form_cart_item_before_$key", $item, $form );
29 29
 
30
-					// Item name.
31
-					if ( 'name' == $key ) {
30
+                    // Item name.
31
+                    if ( 'name' == $key ) {
32 32
 
33
-						// Display the name.
34
-						echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>';
33
+                        // Display the name.
34
+                        echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>';
35 35
 
36
-						// And an optional description.
36
+                        // And an optional description.
37 37
                         $description = $item->get_description();
38 38
 
39 39
                         if ( ! empty( $description ) ) {
40 40
                             $description = wp_kses_post( $description );
41 41
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
42
-						}
42
+                        }
43 43
 
44
-						// Price help text.
44
+                        // Price help text.
45 45
                         $description = getpaid_item_recurring_price_help_text( $item, $currency );
46 46
                         if ( $description ) {
47 47
                             echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>";
48
-						}
48
+                        }
49 49
 
50
-					}
50
+                    }
51 51
 
52
-					// Item price.
53
-					if ( 'price' == $key ) {
52
+                    // Item price.
53
+                    if ( 'price' == $key ) {
54 54
 
55
-						// Set the currency position.
56
-						$position = wpinv_currency_position();
55
+                        // Set the currency position.
56
+                        $position = wpinv_currency_position();
57 57
 
58
-						if ( $position == 'left_space' ) {
59
-							$position = 'left';
60
-						}
58
+                        if ( $position == 'left_space' ) {
59
+                            $position = 'left';
60
+                        }
61 61
 
62
-						if ( $position == 'right_space' ) {
63
-							$position = 'right';
64
-						}
62
+                        if ( $position == 'right_space' ) {
63
+                            $position = 'right';
64
+                        }
65 65
 
66
-						if ( $item->user_can_set_their_price() ) {
67
-							$price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
68
-							$minimum          = (float) $item->get_minimum_price();
69
-							$validate_minimum = '';
70
-							$class            = '';
71
-							$data_minimum     = '';
66
+                        if ( $item->user_can_set_their_price() ) {
67
+                            $price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
68
+                            $minimum          = (float) $item->get_minimum_price();
69
+                            $validate_minimum = '';
70
+                            $class            = '';
71
+                            $data_minimum     = '';
72 72
 
73
-							if ( $minimum > 0 ) {
74
-								$validate_minimum = sprintf(
75
-									esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
76
-									sanitize_text_field( wpinv_price( $minimum, $currency ) )
77
-								);
73
+                            if ( $minimum > 0 ) {
74
+                                $validate_minimum = sprintf(
75
+                                    esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
76
+                                    sanitize_text_field( wpinv_price( $minimum, $currency ) )
77
+                                );
78 78
 
79
-								$class = 'getpaid-validate-minimum-amount';
79
+                                $class = 'getpaid-validate-minimum-amount';
80 80
 
81
-								$data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
82
-							}
81
+                                $data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
82
+                            }
83 83
 
84
-							?>
84
+                            ?>
85 85
 								<div class="input-group input-group-sm">
86 86
 									<?php if( 'left' == $position ) : ?>
87 87
 										<div class="input-group-prepend">
@@ -105,37 +105,37 @@  discard block
 block discarded – undo
105 105
 								</div>
106 106
 
107 107
 							<?php
108
-						} else {
109
-							echo wpinv_price( $item->get_price(), $currency );
110
-							?>
108
+                        } else {
109
+                            echo wpinv_price( $item->get_price(), $currency );
110
+                            ?>
111 111
 								<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() ); ?>'>
112 112
 							<?php
113
-						}
114
-					}
113
+                        }
114
+                    }
115 115
 
116
-					// Item quantity.
117
-					if ( 'quantity' == $key ) {
116
+                    // Item quantity.
117
+                    if ( 'quantity' == $key ) {
118 118
 
119
-						if ( $item->allows_quantities() ) {
120
-							?>
119
+                        if ( $item->allows_quantities() ) {
120
+                            ?>
121 121
 								<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(); ?>' min='1' required>
122 122
 							<?php
123
-						} else {
124
-							echo (float) $item->get_quantity();
125
-							echo '&nbsp;&nbsp;&nbsp;';
126
-							?>
123
+                        } else {
124
+                            echo (float) $item->get_quantity();
125
+                            echo '&nbsp;&nbsp;&nbsp;';
126
+                            ?>
127 127
 								<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(); ?>'>
128 128
 							<?php
129
-						}
130
-					}
129
+                        }
130
+                    }
131 131
 
132
-					// Item sub total.
133
-					if ( 'subtotal' == $key ) {
134
-						echo wpinv_price( $item->get_sub_total(), $currency );
135
-					}
132
+                    // Item sub total.
133
+                    if ( 'subtotal' == $key ) {
134
+                        echo wpinv_price( $item->get_sub_total(), $currency );
135
+                    }
136 136
 
137
-					do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
138
-				?>
137
+                    do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
138
+                ?>
139 139
 
140 140
 			</div>
141 141
 
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -7,116 +7,116 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-do_action( 'getpaid_before_payment_form_cart_item', $form, $item );
12
+do_action('getpaid_before_payment_form_cart_item', $form, $item);
13 13
 
14 14
 $currency = $form->get_currency();
15 15
 
16 16
 ?>
17
-<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required'  : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'>
17
+<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'>
18 18
 
19 19
 	<div class="form-row needs-validation">
20 20
 
21
-		<?php foreach ( array_keys( $columns ) as $key ) : ?>
21
+		<?php foreach (array_keys($columns) as $key) : ?>
22 22
 
23
-			<div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>-<?php echo $item->get_id(); ?>">
23
+			<div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>-<?php echo $item->get_id(); ?>">
24 24
 
25 25
 				<?php
26 26
 
27 27
 					// Fires before printing a line item column.
28
-					do_action( "getpaid_form_cart_item_before_$key", $item, $form );
28
+					do_action("getpaid_form_cart_item_before_$key", $item, $form);
29 29
 
30 30
 					// Item name.
31
-					if ( 'name' == $key ) {
31
+					if ('name' == $key) {
32 32
 
33 33
 						// Display the name.
34
-						echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>';
34
+						echo '<div class="mb-1">' . sanitize_text_field($item->get_name()) . '</div>';
35 35
 
36 36
 						// And an optional description.
37 37
                         $description = $item->get_description();
38 38
 
39
-                        if ( ! empty( $description ) ) {
40
-                            $description = wp_kses_post( $description );
39
+                        if (!empty($description)) {
40
+                            $description = wp_kses_post($description);
41 41
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
42 42
 						}
43 43
 
44 44
 						// Price help text.
45
-                        $description = getpaid_item_recurring_price_help_text( $item, $currency );
46
-                        if ( $description ) {
45
+                        $description = getpaid_item_recurring_price_help_text($item, $currency);
46
+                        if ($description) {
47 47
                             echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>";
48 48
 						}
49 49
 
50 50
 					}
51 51
 
52 52
 					// Item price.
53
-					if ( 'price' == $key ) {
53
+					if ('price' == $key) {
54 54
 
55 55
 						// Set the currency position.
56 56
 						$position = wpinv_currency_position();
57 57
 
58
-						if ( $position == 'left_space' ) {
58
+						if ($position == 'left_space') {
59 59
 							$position = 'left';
60 60
 						}
61 61
 
62
-						if ( $position == 'right_space' ) {
62
+						if ($position == 'right_space') {
63 63
 							$position = 'right';
64 64
 						}
65 65
 
66
-						if ( $item->user_can_set_their_price() ) {
67
-							$price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
66
+						if ($item->user_can_set_their_price()) {
67
+							$price            = max((float) $item->get_price(), (float) $item->get_minimum_price());
68 68
 							$minimum          = (float) $item->get_minimum_price();
69 69
 							$validate_minimum = '';
70 70
 							$class            = '';
71 71
 							$data_minimum     = '';
72 72
 
73
-							if ( $minimum > 0 ) {
73
+							if ($minimum > 0) {
74 74
 								$validate_minimum = sprintf(
75
-									esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
76
-									sanitize_text_field( wpinv_price( $minimum, $currency ) )
75
+									esc_attr__('The minimum allowed amount is %s', 'invoicing'),
76
+									sanitize_text_field(wpinv_price($minimum, $currency))
77 77
 								);
78 78
 
79 79
 								$class = 'getpaid-validate-minimum-amount';
80 80
 
81
-								$data_minimum     = "data-minimum-amount='" . esc_attr( getpaid_unstandardize_amount( $minimum ) ) . "'";
81
+								$data_minimum = "data-minimum-amount='" . esc_attr(getpaid_unstandardize_amount($minimum)) . "'";
82 82
 							}
83 83
 
84 84
 							?>
85 85
 								<div class="input-group input-group-sm">
86
-									<?php if( 'left' == $position ) : ?>
86
+									<?php if ('left' == $position) : ?>
87 87
 										<div class="input-group-prepend">
88
-											<span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
88
+											<span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
89 89
 										</div>
90 90
 									<?php endif; ?>
91 91
 
92
-									<input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr( getpaid_unstandardize_amount( $price ) ); ?>" placeholder="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price() ) ); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;">
92
+									<input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo esc_attr(getpaid_unstandardize_amount($price)); ?>" placeholder="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price())); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;">
93 93
 
94
-									<?php if ( ! empty( $validate_minimum ) ) : ?>
94
+									<?php if (!empty($validate_minimum)) : ?>
95 95
 										<div class="invalid-tooltip">
96 96
 											<?php echo $validate_minimum; ?>
97 97
 										</div>
98 98
 									<?php endif; ?>
99 99
 
100
-									<?php if( 'left' != $position ) : ?>
100
+									<?php if ('left' != $position) : ?>
101 101
 										<div class="input-group-append">
102
-											<span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
102
+											<span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
103 103
 										</div>
104 104
 									<?php endif; ?>
105 105
 								</div>
106 106
 
107 107
 							<?php
108 108
 						} else {
109
-							echo wpinv_price( $item->get_price(), $currency );
109
+							echo wpinv_price($item->get_price(), $currency);
110 110
 							?>
111
-								<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() ); ?>'>
111
+								<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()); ?>'>
112 112
 							<?php
113 113
 						}
114 114
 					}
115 115
 
116 116
 					// Item quantity.
117
-					if ( 'quantity' == $key ) {
117
+					if ('quantity' == $key) {
118 118
 
119
-						if ( $item->allows_quantities() ) {
119
+						if ($item->allows_quantities()) {
120 120
 							?>
121 121
 								<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(); ?>' min='1' required>
122 122
 							<?php
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 					}
131 131
 
132 132
 					// Item sub total.
133
-					if ( 'subtotal' == $key ) {
134
-						echo wpinv_price( $item->get_sub_total(), $currency );
133
+					if ('subtotal' == $key) {
134
+						echo wpinv_price($item->get_sub_total(), $currency);
135 135
 					}
136 136
 
137
-					do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
137
+					do_action("getpaid_payment_form_cart_item_$key", $item, $form);
138 138
 				?>
139 139
 
140 140
 			</div>
@@ -145,4 +145,4 @@  discard block
 block discarded – undo
145 145
 
146 146
 </div>
147 147
 <?php
148
-do_action(  'getpaid_payment_form_cart_item', $form, $item );
148
+do_action('getpaid_payment_form_cart_item', $form, $item);
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +529 added lines, -529 removed lines patch added patch discarded remove patch
@@ -14,592 +14,592 @@
 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 the translation of the plugin.
158
-	 *
159
-	 * @since 1.0
160
-	 */
161
-	public function load_textdomain( $locale = NULL ) {
162
-		if ( empty( $locale ) ) {
163
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
164
-		}
165
-
166
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
167
-
168
-		unload_textdomain( 'invoicing' );
169
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
170
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
171
-
172
-		/**
173
-		 * Define language constants.
174
-		 */
175
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
176
-	}
177
-
178
-	/**
179
-	 * Include required core files used in admin and on the frontend.
180
-	 */
181
-	public function includes() {
182
-
183
-		// Start with the settings.
184
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
185
-
186
-		// Packages/libraries.
187
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
188
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
189
-
190
-		// Load functions.
191
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
192
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
193
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
195
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
196
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
197
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
200
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
206
-
207
-		// Register autoloader.
208
-		try {
209
-			spl_autoload_register( array( $this, 'autoload' ), true );
210
-		} catch ( Exception $e ) {
211
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
212
-		}
213
-
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
216
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
217
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
218
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
219
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
220
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
221
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
222
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
235
-
236
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
237
-			GetPaid_Post_Types_Admin::init();
238
-
239
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
240
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
241
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
242
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
243
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
244
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
245
-			// load the user class only on the users.php page
246
-			global $pagenow;
247
-			if($pagenow=='users.php'){
248
-				new WPInv_Admin_Users();
249
-			}
250
-		}
251
-
252
-		// Register cli commands
253
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
254
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
255
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
256
-		}
257
-
258
-	}
259
-
260
-	/**
261
-	 * Class autoloader
262
-	 *
263
-	 * @param       string $class_name The name of the class to load.
264
-	 * @access      public
265
-	 * @since       1.0.19
266
-	 * @return      void
267
-	 */
268
-	public function autoload( $class_name ) {
269
-
270
-		// Normalize the class name...
271
-		$class_name  = strtolower( $class_name );
272
-
273
-		// ... and make sure it is our class.
274
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
275
-			return;
276
-		}
277
-
278
-		// Next, prepare the file name from the class.
279
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
280
-
281
-		// Base path of the classes.
282
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
283
-
284
-		// And an array of possible locations in order of importance.
285
-		$locations = array(
286
-			"$plugin_path/includes",
287
-			"$plugin_path/includes/data-stores",
288
-			"$plugin_path/includes/gateways",
289
-			"$plugin_path/includes/payments",
290
-			"$plugin_path/includes/geolocation",
291
-			"$plugin_path/includes/reports",
292
-			"$plugin_path/includes/api",
293
-			"$plugin_path/includes/admin",
294
-			"$plugin_path/includes/admin/meta-boxes",
295
-		);
296
-
297
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
298
-
299
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
-				include trailingslashit( $location ) . $file_name;
301
-				break;
302
-			}
303
-
304
-		}
305
-
306
-	}
307
-
308
-	/**
309
-	 * Inits hooks etc.
310
-	 */
311
-	public function init() {
312
-
313
-		// Fires before getpaid inits.
314
-		do_action( 'before_getpaid_init', $this );
315
-
316
-		// Maybe upgrade.
317
-		$this->maybe_upgrade_database();
318
-
319
-		// Load default gateways.
320
-		$gateways = apply_filters(
321
-			'getpaid_default_gateways',
322
-			array(
323
-				'manual'        => 'GetPaid_Manual_Gateway',
324
-				'paypal'        => 'GetPaid_Paypal_Gateway',
325
-				'worldpay'      => 'GetPaid_Worldpay_Gateway',
326
-				'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
327
-				'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
328
-			)
329
-		);
330
-
331
-		foreach ( $gateways as $id => $class ) {
332
-			$this->gateways[ $id ] = new $class();
333
-		}
334
-
335
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
336
-			GetPaid_Installer::rename_gateways_label();
337
-			update_option( 'wpinv_renamed_gateways', 'yes' );
338
-		}
339
-
340
-		// Fires after getpaid inits.
341
-		do_action( 'getpaid_init', $this );
342
-
343
-	}
344
-
345
-	/**
346
-	 * Checks if this is an IPN request and processes it.
347
-	 */
348
-	public function maybe_process_ipn() {
349
-
350
-		// Ensure that this is an IPN request.
351
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
352
-			return;
353
-		}
354
-
355
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
356
-
357
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
358
-		do_action( "wpinv_verify_{$gateway}_ipn" );
359
-		exit;
360
-
361
-	}
362
-
363
-	public function enqueue_scripts() {
364
-
365
-		// Fires before adding scripts.
366
-		do_action( 'getpaid_enqueue_scripts' );
367
-
368
-		$localize                         = array();
369
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
370
-		$localize['thousands']            = wpinv_thousands_separator();
371
-		$localize['decimals']             = wpinv_decimal_separator();
372
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
373
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
374
-		$localize['UseTaxes']             = wpinv_use_taxes();
375
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
376
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
377
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
378
-
379
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
380
-
381
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
382
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
383
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
384
-	}
385
-
386
-	public function wpinv_actions() {
387
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
388
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
389
-		}
390
-	}
391
-
392
-	/**
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 the translation of the plugin.
158
+     *
159
+     * @since 1.0
160
+     */
161
+    public function load_textdomain( $locale = NULL ) {
162
+        if ( empty( $locale ) ) {
163
+            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
164
+        }
165
+
166
+        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
167
+
168
+        unload_textdomain( 'invoicing' );
169
+        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
170
+        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
171
+
172
+        /**
173
+         * Define language constants.
174
+         */
175
+        require_once( WPINV_PLUGIN_DIR . 'language.php' );
176
+    }
177
+
178
+    /**
179
+     * Include required core files used in admin and on the frontend.
180
+     */
181
+    public function includes() {
182
+
183
+        // Start with the settings.
184
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
185
+
186
+        // Packages/libraries.
187
+        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
188
+        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
189
+
190
+        // Load functions.
191
+        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
192
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
193
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
194
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
195
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
196
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
197
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
198
+        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
199
+        require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
200
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
201
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
202
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
203
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
204
+        require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
205
+        require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
206
+
207
+        // Register autoloader.
208
+        try {
209
+            spl_autoload_register( array( $this, 'autoload' ), true );
210
+        } catch ( Exception $e ) {
211
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
212
+        }
213
+
214
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
215
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
216
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
217
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
218
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
219
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
220
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
221
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
222
+        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
223
+        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
224
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
225
+        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
226
+        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
227
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
228
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
229
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
230
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
231
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
232
+        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
233
+        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
234
+        require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
235
+
236
+        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
237
+            GetPaid_Post_Types_Admin::init();
238
+
239
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
240
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
241
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
242
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
243
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
244
+            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
245
+            // load the user class only on the users.php page
246
+            global $pagenow;
247
+            if($pagenow=='users.php'){
248
+                new WPInv_Admin_Users();
249
+            }
250
+        }
251
+
252
+        // Register cli commands
253
+        if ( defined( 'WP_CLI' ) && WP_CLI ) {
254
+            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
255
+            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
256
+        }
257
+
258
+    }
259
+
260
+    /**
261
+     * Class autoloader
262
+     *
263
+     * @param       string $class_name The name of the class to load.
264
+     * @access      public
265
+     * @since       1.0.19
266
+     * @return      void
267
+     */
268
+    public function autoload( $class_name ) {
269
+
270
+        // Normalize the class name...
271
+        $class_name  = strtolower( $class_name );
272
+
273
+        // ... and make sure it is our class.
274
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
275
+            return;
276
+        }
277
+
278
+        // Next, prepare the file name from the class.
279
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
280
+
281
+        // Base path of the classes.
282
+        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
283
+
284
+        // And an array of possible locations in order of importance.
285
+        $locations = array(
286
+            "$plugin_path/includes",
287
+            "$plugin_path/includes/data-stores",
288
+            "$plugin_path/includes/gateways",
289
+            "$plugin_path/includes/payments",
290
+            "$plugin_path/includes/geolocation",
291
+            "$plugin_path/includes/reports",
292
+            "$plugin_path/includes/api",
293
+            "$plugin_path/includes/admin",
294
+            "$plugin_path/includes/admin/meta-boxes",
295
+        );
296
+
297
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
298
+
299
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
+                include trailingslashit( $location ) . $file_name;
301
+                break;
302
+            }
303
+
304
+        }
305
+
306
+    }
307
+
308
+    /**
309
+     * Inits hooks etc.
310
+     */
311
+    public function init() {
312
+
313
+        // Fires before getpaid inits.
314
+        do_action( 'before_getpaid_init', $this );
315
+
316
+        // Maybe upgrade.
317
+        $this->maybe_upgrade_database();
318
+
319
+        // Load default gateways.
320
+        $gateways = apply_filters(
321
+            'getpaid_default_gateways',
322
+            array(
323
+                'manual'        => 'GetPaid_Manual_Gateway',
324
+                'paypal'        => 'GetPaid_Paypal_Gateway',
325
+                'worldpay'      => 'GetPaid_Worldpay_Gateway',
326
+                'bank_transfer' => 'GetPaid_Bank_Transfer_Gateway',
327
+                'authorizenet'  => 'GetPaid_Authorize_Net_Gateway',
328
+            )
329
+        );
330
+
331
+        foreach ( $gateways as $id => $class ) {
332
+            $this->gateways[ $id ] = new $class();
333
+        }
334
+
335
+        if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
336
+            GetPaid_Installer::rename_gateways_label();
337
+            update_option( 'wpinv_renamed_gateways', 'yes' );
338
+        }
339
+
340
+        // Fires after getpaid inits.
341
+        do_action( 'getpaid_init', $this );
342
+
343
+    }
344
+
345
+    /**
346
+     * Checks if this is an IPN request and processes it.
347
+     */
348
+    public function maybe_process_ipn() {
349
+
350
+        // Ensure that this is an IPN request.
351
+        if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
352
+            return;
353
+        }
354
+
355
+        $gateway = wpinv_clean( $_GET['wpi-gateway'] );
356
+
357
+        do_action( 'wpinv_verify_payment_ipn', $gateway );
358
+        do_action( "wpinv_verify_{$gateway}_ipn" );
359
+        exit;
360
+
361
+    }
362
+
363
+    public function enqueue_scripts() {
364
+
365
+        // Fires before adding scripts.
366
+        do_action( 'getpaid_enqueue_scripts' );
367
+
368
+        $localize                         = array();
369
+        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
370
+        $localize['thousands']            = wpinv_thousands_separator();
371
+        $localize['decimals']             = wpinv_decimal_separator();
372
+        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
373
+        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
374
+        $localize['UseTaxes']             = wpinv_use_taxes();
375
+        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
376
+        $localize['loading']              = __( 'Loading...', 'invoicing' );
377
+        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
378
+
379
+        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
380
+
381
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
382
+        wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
383
+        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
384
+    }
385
+
386
+    public function wpinv_actions() {
387
+        if ( isset( $_REQUEST['wpi_action'] ) ) {
388
+            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
389
+        }
390
+    }
391
+
392
+    /**
393 393
      * Fires an action after verifying that a user can fire them.
394
-	 *
395
-	 * Note: If the action is on an invoice, subscription etc, esure that the
396
-	 * current user owns the invoice/subscription.
394
+     *
395
+     * Note: If the action is on an invoice, subscription etc, esure that the
396
+     * current user owns the invoice/subscription.
397 397
      */
398 398
     public function maybe_do_authenticated_action() {
399 399
 
400
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
400
+        if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
401
+
402
+            $key  = sanitize_key( $_REQUEST['getpaid-action'] );
403
+            $data = wp_unslash( $_REQUEST );
404
+            if ( is_user_logged_in() ) {
405
+                do_action( "getpaid_authenticated_action_$key", $data );
406
+            }
407
+
408
+            do_action( "getpaid_unauthenticated_action_$key", $data );
409
+
410
+        }
401 411
 
402
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
403
-			$data = wp_unslash( $_REQUEST );
404
-			if ( is_user_logged_in() ) {
405
-				do_action( "getpaid_authenticated_action_$key", $data );
406
-			}
412
+    }
407 413
 
408
-			do_action( "getpaid_unauthenticated_action_$key", $data );
414
+    public function pre_get_posts( $wp_query ) {
409 415
 
410
-		}
416
+        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() ) {
417
+            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
418
+        }
411 419
 
420
+        return $wp_query;
412 421
     }
413 422
 
414
-	public function pre_get_posts( $wp_query ) {
415
-
416
-		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() ) {
417
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
418
-		}
419
-
420
-		return $wp_query;
421
-	}
422
-
423
-	/**
424
-	 * Register widgets
425
-	 *
426
-	 */
427
-	public function register_widgets() {
428
-
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
-		$widgets = apply_filters(
436
-			'getpaid_widget_classes',
437
-			array(
438
-				'WPInv_Checkout_Widget',
439
-				'WPInv_History_Widget',
440
-				'WPInv_Receipt_Widget',
441
-				'WPInv_Subscriptions_Widget',
442
-				'WPInv_Buy_Item_Widget',
443
-				'WPInv_Messages_Widget',
444
-				'WPInv_GetPaid_Widget'
445
-			)
446
-		);
447
-
448
-		foreach ( $widgets as $widget ) {
449
-			register_widget( $widget );
450
-		}
423
+    /**
424
+     * Register widgets
425
+     *
426
+     */
427
+    public function register_widgets() {
428
+
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
+        $widgets = apply_filters(
436
+            'getpaid_widget_classes',
437
+            array(
438
+                'WPInv_Checkout_Widget',
439
+                'WPInv_History_Widget',
440
+                'WPInv_Receipt_Widget',
441
+                'WPInv_Subscriptions_Widget',
442
+                'WPInv_Buy_Item_Widget',
443
+                'WPInv_Messages_Widget',
444
+                'WPInv_GetPaid_Widget'
445
+            )
446
+        );
447
+
448
+        foreach ( $widgets as $widget ) {
449
+            register_widget( $widget );
450
+        }
451 451
 		
452
-	}
452
+    }
453 453
 
454
-	/**
455
-	 * Upgrades the database.
456
-	 *
457
-	 * @since 2.0.2
458
-	 */
459
-	public function maybe_upgrade_database() {
454
+    /**
455
+     * Upgrades the database.
456
+     *
457
+     * @since 2.0.2
458
+     */
459
+    public function maybe_upgrade_database() {
460 460
 
461
-		$wpi_version = get_option( 'wpinv_version', 0 );
461
+        $wpi_version = get_option( 'wpinv_version', 0 );
462 462
 
463
-		if ( $wpi_version == WPINV_VERSION ) {
464
-			return;
465
-		}
463
+        if ( $wpi_version == WPINV_VERSION ) {
464
+            return;
465
+        }
466 466
 
467
-		$installer = new GetPaid_Installer();
467
+        $installer = new GetPaid_Installer();
468 468
 
469
-		if ( empty( $wpi_version ) ) {
470
-			return $installer->upgrade_db( 0 );
471
-		}
469
+        if ( empty( $wpi_version ) ) {
470
+            return $installer->upgrade_db( 0 );
471
+        }
472 472
 
473
-		$upgrades  = array(
474
-			'0.0.5' => '004',
475
-			'1.0.3' => '102',
476
-			'2.0.0' => '118',
477
-			'2.0.8' => '207',
478
-		);
473
+        $upgrades  = array(
474
+            '0.0.5' => '004',
475
+            '1.0.3' => '102',
476
+            '2.0.0' => '118',
477
+            '2.0.8' => '207',
478
+        );
479 479
 
480
-		foreach ( $upgrades as $key => $method ) {
480
+        foreach ( $upgrades as $key => $method ) {
481 481
 
482
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
483
-				return $installer->upgrade_db( $method );
484
-			}
482
+            if ( version_compare( $wpi_version, $key, '<' ) ) {
483
+                return $installer->upgrade_db( $method );
484
+            }
485 485
 
486
-		}
486
+        }
487 487
 
488
-	}
488
+    }
489 489
 
490
-	/**
491
-	 * Flushes the permalinks if needed.
492
-	 *
493
-	 * @since 2.0.8
494
-	 */
495
-	public function maybe_flush_permalinks() {
490
+    /**
491
+     * Flushes the permalinks if needed.
492
+     *
493
+     * @since 2.0.8
494
+     */
495
+    public function maybe_flush_permalinks() {
496 496
 
497
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
497
+        $flush = get_option( 'wpinv_flush_permalinks', 0 );
498 498
 
499
-		if ( ! empty( $flush ) ) {
500
-			flush_rewrite_rules();
501
-			delete_option( 'wpinv_flush_permalinks' );
502
-		}
499
+        if ( ! empty( $flush ) ) {
500
+            flush_rewrite_rules();
501
+            delete_option( 'wpinv_flush_permalinks' );
502
+        }
503 503
 
504
-	}
504
+    }
505 505
 
506
-	/**
507
-	 * Remove our pages from yoast sitemaps.
508
-	 *
509
-	 * @since 1.0.19
510
-	 * @param int[] $excluded_posts_ids
511
-	 */
512
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
506
+    /**
507
+     * Remove our pages from yoast sitemaps.
508
+     *
509
+     * @since 1.0.19
510
+     * @param int[] $excluded_posts_ids
511
+     */
512
+    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
513 513
 
514
-		// Ensure that we have an array.
515
-		if ( ! is_array( $excluded_posts_ids ) ) {
516
-			$excluded_posts_ids = array();
517
-		}
514
+        // Ensure that we have an array.
515
+        if ( ! is_array( $excluded_posts_ids ) ) {
516
+            $excluded_posts_ids = array();
517
+        }
518 518
 
519
-		// Prepare our pages.
520
-		$our_pages = array();
519
+        // Prepare our pages.
520
+        $our_pages = array();
521 521
 
522
-		// Checkout page.
523
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
522
+        // Checkout page.
523
+        $our_pages[] = wpinv_get_option( 'checkout_page', false );
524 524
 
525
-		// Success page.
526
-		$our_pages[] = wpinv_get_option( 'success_page', false );
525
+        // Success page.
526
+        $our_pages[] = wpinv_get_option( 'success_page', false );
527 527
 
528
-		// Failure page.
529
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
528
+        // Failure page.
529
+        $our_pages[] = wpinv_get_option( 'failure_page', false );
530 530
 
531
-		// History page.
532
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
531
+        // History page.
532
+        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
533 533
 
534
-		// Subscriptions page.
535
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
534
+        // Subscriptions page.
535
+        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
536 536
 
537
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
537
+        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
538 538
 
539
-		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
540
-		return array_unique( $excluded_posts_ids );
539
+        $excluded_posts_ids = $excluded_posts_ids + $our_pages;
540
+        return array_unique( $excluded_posts_ids );
541 541
 
542
-	}
542
+    }
543 543
 
544
-	/**
545
-	 * Displays additional footer code.
546
-	 * 
547
-	 * @since 2.0.0
548
-	 */
549
-	public function wp_footer() {
550
-		wpinv_get_template( 'frontend-footer.php' );
551
-	}
544
+    /**
545
+     * Displays additional footer code.
546
+     * 
547
+     * @since 2.0.0
548
+     */
549
+    public function wp_footer() {
550
+        wpinv_get_template( 'frontend-footer.php' );
551
+    }
552 552
 
553
-	/**
554
-	 * Displays additional header code.
555
-	 * 
556
-	 * @since 2.0.0
557
-	 */
558
-	public function wp_head() {
559
-		wpinv_get_template( 'frontend-head.php' );
560
-	}
553
+    /**
554
+     * Displays additional header code.
555
+     * 
556
+     * @since 2.0.0
557
+     */
558
+    public function wp_head() {
559
+        wpinv_get_template( 'frontend-head.php' );
560
+    }
561 561
 
562
-	/**
563
-	 * Custom query vars.
564
-	 *
565
-	 */
566
-	public function custom_query_vars( $vars ) {
562
+    /**
563
+     * Custom query vars.
564
+     *
565
+     */
566
+    public function custom_query_vars( $vars ) {
567 567
         $vars[] = 'getpaid-ipn';
568 568
         return $vars;
569
-	}
569
+    }
570 570
 
571
-	/**
572
-	 * Add rewrite tags and rules.
573
-	 *
574
-	 */
575
-	public function add_rewrite_rule() {
571
+    /**
572
+     * Add rewrite tags and rules.
573
+     *
574
+     */
575
+    public function add_rewrite_rule() {
576 576
         $tag = 'getpaid-ipn';
577 577
         add_rewrite_tag( "%$tag%", '([^&]+)' );
578 578
         add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' );
579
-	}
579
+    }
580 580
 
581
-	/**
582
-	 * Processes non-query string ipns.
583
-	 *
584
-	 */
585
-	public function maybe_process_new_ipn( $query ) {
581
+    /**
582
+     * Processes non-query string ipns.
583
+     *
584
+     */
585
+    public function maybe_process_new_ipn( $query ) {
586 586
 
587 587
         if ( is_admin() || ! $query->is_main_query() ) {
588 588
             return;
589 589
         }
590 590
 
591
-		$gateway = get_query_var( 'getpaid-ipn' );
591
+        $gateway = get_query_var( 'getpaid-ipn' );
592 592
 
593 593
         if ( ! empty( $gateway ) ){
594 594
 
595
-			$gateway = sanitize_text_field( $gateway );
596
-			nocache_headers();
597
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
598
-			do_action( "wpinv_verify_{$gateway}_ipn" );
599
-			exit;
595
+            $gateway = sanitize_text_field( $gateway );
596
+            nocache_headers();
597
+            do_action( 'wpinv_verify_payment_ipn', $gateway );
598
+            do_action( "wpinv_verify_{$gateway}_ipn" );
599
+            exit;
600 600
 
601 601
         }
602 602
 
603
-	}
603
+    }
604 604
 
605 605
 }
Please login to merge, or discard this patch.
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Main Invoicing class.
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param string $prop The prop to set.
57 57
 	 * @param mixed $value The value to retrieve.
58 58
 	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
59
+	public function set($prop, $value) {
60
+		$this->data[$prop] = $value;
61 61
 	}
62 62
 
63 63
 	/**
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 	 * @param string $prop The prop to set.
67 67
 	 * @return mixed The value.
68 68
 	 */
69
-	public function get( $prop ) {
69
+	public function get($prop) {
70 70
 
71
-		if ( isset( $this->data[ $prop ] ) ) {
72
-			return $this->data[ $prop ];
71
+		if (isset($this->data[$prop])) {
72
+			return $this->data[$prop];
73 73
 		}
74 74
 
75 75
 		return null;
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
 	public function set_properties() {
82 82
 
83 83
 		// Sessions.
84
-		$this->set( 'session', new WPInv_Session_Handler() );
85
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
84
+		$this->set('session', new WPInv_Session_Handler());
85
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
86 86
 		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
87 87
 
88 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() );
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 101
 
102 102
 	}
103 103
 
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 	 * Define plugin constants.
106 106
 	 */
107 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 ) );
108
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
109
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
110 110
 		$this->version = WPINV_VERSION;
111 111
 	}
112 112
 
@@ -117,27 +117,27 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	protected function init_hooks() {
119 119
 		/* Internationalize the text strings used. */
120
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
120
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
121 121
 
122 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
-        add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
136
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
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
+        add_action('init', array($this, 'add_rewrite_rule'), 10, 0);
136
+		add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1);
137 137
 
138 138
 		// Fires after registering actions.
139
-		do_action( 'wpinv_actions', $this );
140
-		do_action( 'getpaid_actions', $this );
139
+		do_action('wpinv_actions', $this);
140
+		do_action('getpaid_actions', $this);
141 141
 
142 142
 	}
143 143
 
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 		/* Internationalize the text strings used. */
146 146
 		$this->load_textdomain();
147 147
 
148
-		do_action( 'wpinv_loaded' );
148
+		do_action('wpinv_loaded');
149 149
 
150 150
 		// Fix oxygen page builder conflict
151
-		if ( function_exists( 'ct_css_output' ) ) {
151
+		if (function_exists('ct_css_output')) {
152 152
 			wpinv_oxygen_fix_conflict();
153 153
 		}
154 154
 	}
@@ -158,21 +158,21 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @since 1.0
160 160
 	 */
161
-	public function load_textdomain( $locale = NULL ) {
162
-		if ( empty( $locale ) ) {
163
-			$locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
161
+	public function load_textdomain($locale = NULL) {
162
+		if (empty($locale)) {
163
+			$locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
164 164
 		}
165 165
 
166
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
166
+		$locale = apply_filters('plugin_locale', $locale, 'invoicing');
167 167
 
168
-		unload_textdomain( 'invoicing' );
169
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
170
-		load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
168
+		unload_textdomain('invoicing');
169
+		load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
170
+		load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
171 171
 
172 172
 		/**
173 173
 		 * Define language constants.
174 174
 		 */
175
-		require_once( WPINV_PLUGIN_DIR . 'language.php' );
175
+		require_once(WPINV_PLUGIN_DIR . 'language.php');
176 176
 	}
177 177
 
178 178
 	/**
@@ -181,78 +181,78 @@  discard block
 block discarded – undo
181 181
 	public function includes() {
182 182
 
183 183
 		// Start with the settings.
184
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
184
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
185 185
 
186 186
 		// Packages/libraries.
187
-		require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
188
-		require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
187
+		require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
188
+		require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
189 189
 
190 190
 		// Load functions.
191
-		require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
192
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
193
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
194
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
195
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
196
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
197
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
198
-		require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
199
-		require_once( WPINV_PLUGIN_DIR . 'includes/subscription-functions.php' );
200
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
201
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
202
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
203
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
204
-		require_once( WPINV_PLUGIN_DIR . 'includes/user-functions.php' );
205
-		require_once( WPINV_PLUGIN_DIR . 'includes/error-functions.php' );
191
+		require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php');
192
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
193
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
194
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
195
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
196
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
197
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
198
+		require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php');
199
+		require_once(WPINV_PLUGIN_DIR . 'includes/subscription-functions.php');
200
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
201
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
202
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
203
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
204
+		require_once(WPINV_PLUGIN_DIR . 'includes/user-functions.php');
205
+		require_once(WPINV_PLUGIN_DIR . 'includes/error-functions.php');
206 206
 
207 207
 		// Register autoloader.
208 208
 		try {
209
-			spl_autoload_register( array( $this, 'autoload' ), true );
210
-		} catch ( Exception $e ) {
211
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
209
+			spl_autoload_register(array($this, 'autoload'), true);
210
+		} catch (Exception $e) {
211
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
212 212
 		}
213 213
 
214
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
215
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
216
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
217
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
218
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
219
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
220
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
221
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
222
-		require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
223
-		require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
224
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
225
-		require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
226
-		require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
227
-		require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
228
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
229
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
230
-		require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
231
-		require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
232
-		require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
233
-		require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
234
-		require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
235
-
236
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
214
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
215
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
216
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
217
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
218
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
219
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
220
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
221
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
222
+		require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
223
+		require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
224
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
225
+		require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
226
+		require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
227
+		require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
228
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
229
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
230
+		require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
231
+		require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
232
+		require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
233
+		require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
234
+		require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
235
+
236
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
237 237
 			GetPaid_Post_Types_Admin::init();
238 238
 
239
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
240
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
241
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
242
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
243
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
244
-			require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
239
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
240
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
241
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
242
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
243
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
244
+			require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
245 245
 			// load the user class only on the users.php page
246 246
 			global $pagenow;
247
-			if($pagenow=='users.php'){
247
+			if ($pagenow == 'users.php') {
248 248
 				new WPInv_Admin_Users();
249 249
 			}
250 250
 		}
251 251
 
252 252
 		// Register cli commands
253
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
254
-			require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
255
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
253
+		if (defined('WP_CLI') && WP_CLI) {
254
+			require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
255
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
256 256
 		}
257 257
 
258 258
 	}
@@ -265,21 +265,21 @@  discard block
 block discarded – undo
265 265
 	 * @since       1.0.19
266 266
 	 * @return      void
267 267
 	 */
268
-	public function autoload( $class_name ) {
268
+	public function autoload($class_name) {
269 269
 
270 270
 		// Normalize the class name...
271
-		$class_name  = strtolower( $class_name );
271
+		$class_name = strtolower($class_name);
272 272
 
273 273
 		// ... and make sure it is our class.
274
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
274
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
275 275
 			return;
276 276
 		}
277 277
 
278 278
 		// Next, prepare the file name from the class.
279
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
279
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
280 280
 
281 281
 		// Base path of the classes.
282
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
282
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
283 283
 
284 284
 		// And an array of possible locations in order of importance.
285 285
 		$locations = array(
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 			"$plugin_path/includes/admin/meta-boxes",
295 295
 		);
296 296
 
297
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
297
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
298 298
 
299
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
300
-				include trailingslashit( $location ) . $file_name;
299
+			if (file_exists(trailingslashit($location) . $file_name)) {
300
+				include trailingslashit($location) . $file_name;
301 301
 				break;
302 302
 			}
303 303
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	public function init() {
312 312
 
313 313
 		// Fires before getpaid inits.
314
-		do_action( 'before_getpaid_init', $this );
314
+		do_action('before_getpaid_init', $this);
315 315
 
316 316
 		// Maybe upgrade.
317 317
 		$this->maybe_upgrade_database();
@@ -328,17 +328,17 @@  discard block
 block discarded – undo
328 328
 			)
329 329
 		);
330 330
 
331
-		foreach ( $gateways as $id => $class ) {
332
-			$this->gateways[ $id ] = new $class();
331
+		foreach ($gateways as $id => $class) {
332
+			$this->gateways[$id] = new $class();
333 333
 		}
334 334
 
335
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
+		if ('yes' != get_option('wpinv_renamed_gateways')) {
336 336
 			GetPaid_Installer::rename_gateways_label();
337
-			update_option( 'wpinv_renamed_gateways', 'yes' );
337
+			update_option('wpinv_renamed_gateways', 'yes');
338 338
 		}
339 339
 
340 340
 		// Fires after getpaid inits.
341
-		do_action( 'getpaid_init', $this );
341
+		do_action('getpaid_init', $this);
342 342
 
343 343
 	}
344 344
 
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 	public function maybe_process_ipn() {
349 349
 
350 350
 		// Ensure that this is an IPN request.
351
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
351
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
352 352
 			return;
353 353
 		}
354 354
 
355
-		$gateway = wpinv_clean( $_GET['wpi-gateway'] );
355
+		$gateway = wpinv_clean($_GET['wpi-gateway']);
356 356
 
357
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
358
-		do_action( "wpinv_verify_{$gateway}_ipn" );
357
+		do_action('wpinv_verify_payment_ipn', $gateway);
358
+		do_action("wpinv_verify_{$gateway}_ipn");
359 359
 		exit;
360 360
 
361 361
 	}
@@ -363,29 +363,29 @@  discard block
 block discarded – undo
363 363
 	public function enqueue_scripts() {
364 364
 
365 365
 		// Fires before adding scripts.
366
-		do_action( 'getpaid_enqueue_scripts' );
366
+		do_action('getpaid_enqueue_scripts');
367 367
 
368 368
 		$localize                         = array();
369
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
369
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
370 370
 		$localize['thousands']            = wpinv_thousands_separator();
371 371
 		$localize['decimals']             = wpinv_decimal_separator();
372
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
373
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
372
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
373
+		$localize['txtComplete']          = __('Continue', 'invoicing');
374 374
 		$localize['UseTaxes']             = wpinv_use_taxes();
375
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
376
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
377
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
375
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
376
+		$localize['loading']              = __('Loading...', 'invoicing');
377
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
378 378
 
379
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
379
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
380 380
 
381
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
382
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ),  $version, true );
383
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
381
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
382
+		wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true);
383
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
384 384
 	}
385 385
 
386 386
 	public function wpinv_actions() {
387
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
388
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
387
+		if (isset($_REQUEST['wpi_action'])) {
388
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
389 389
 		}
390 390
 	}
391 391
 
@@ -397,24 +397,24 @@  discard block
 block discarded – undo
397 397
      */
398 398
     public function maybe_do_authenticated_action() {
399 399
 
400
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
400
+		if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
401 401
 
402
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
403
-			$data = wp_unslash( $_REQUEST );
404
-			if ( is_user_logged_in() ) {
405
-				do_action( "getpaid_authenticated_action_$key", $data );
402
+			$key  = sanitize_key($_REQUEST['getpaid-action']);
403
+			$data = wp_unslash($_REQUEST);
404
+			if (is_user_logged_in()) {
405
+				do_action("getpaid_authenticated_action_$key", $data);
406 406
 			}
407 407
 
408
-			do_action( "getpaid_unauthenticated_action_$key", $data );
408
+			do_action("getpaid_unauthenticated_action_$key", $data);
409 409
 
410 410
 		}
411 411
 
412 412
     }
413 413
 
414
-	public function pre_get_posts( $wp_query ) {
414
+	public function pre_get_posts($wp_query) {
415 415
 
416
-		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() ) {
417
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
416
+		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()) {
417
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type']));
418 418
 		}
419 419
 
420 420
 		return $wp_query;
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 
429 429
 		// Currently, UX Builder does not work particulaly well with SuperDuper.
430 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() ) {
431
+		if (function_exists('ux_builder_is_active') && ux_builder_is_active()) {
432 432
 			return;
433 433
 		}
434 434
 
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 			)
446 446
 		);
447 447
 
448
-		foreach ( $widgets as $widget ) {
449
-			register_widget( $widget );
448
+		foreach ($widgets as $widget) {
449
+			register_widget($widget);
450 450
 		}
451 451
 		
452 452
 	}
@@ -458,29 +458,29 @@  discard block
 block discarded – undo
458 458
 	 */
459 459
 	public function maybe_upgrade_database() {
460 460
 
461
-		$wpi_version = get_option( 'wpinv_version', 0 );
461
+		$wpi_version = get_option('wpinv_version', 0);
462 462
 
463
-		if ( $wpi_version == WPINV_VERSION ) {
463
+		if ($wpi_version == WPINV_VERSION) {
464 464
 			return;
465 465
 		}
466 466
 
467 467
 		$installer = new GetPaid_Installer();
468 468
 
469
-		if ( empty( $wpi_version ) ) {
470
-			return $installer->upgrade_db( 0 );
469
+		if (empty($wpi_version)) {
470
+			return $installer->upgrade_db(0);
471 471
 		}
472 472
 
473
-		$upgrades  = array(
473
+		$upgrades = array(
474 474
 			'0.0.5' => '004',
475 475
 			'1.0.3' => '102',
476 476
 			'2.0.0' => '118',
477 477
 			'2.0.8' => '207',
478 478
 		);
479 479
 
480
-		foreach ( $upgrades as $key => $method ) {
480
+		foreach ($upgrades as $key => $method) {
481 481
 
482
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
483
-				return $installer->upgrade_db( $method );
482
+			if (version_compare($wpi_version, $key, '<')) {
483
+				return $installer->upgrade_db($method);
484 484
 			}
485 485
 
486 486
 		}
@@ -494,11 +494,11 @@  discard block
 block discarded – undo
494 494
 	 */
495 495
 	public function maybe_flush_permalinks() {
496 496
 
497
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
497
+		$flush = get_option('wpinv_flush_permalinks', 0);
498 498
 
499
-		if ( ! empty( $flush ) ) {
499
+		if (!empty($flush)) {
500 500
 			flush_rewrite_rules();
501
-			delete_option( 'wpinv_flush_permalinks' );
501
+			delete_option('wpinv_flush_permalinks');
502 502
 		}
503 503
 
504 504
 	}
@@ -509,10 +509,10 @@  discard block
 block discarded – undo
509 509
 	 * @since 1.0.19
510 510
 	 * @param int[] $excluded_posts_ids
511 511
 	 */
512
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
512
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
513 513
 
514 514
 		// Ensure that we have an array.
515
-		if ( ! is_array( $excluded_posts_ids ) ) {
515
+		if (!is_array($excluded_posts_ids)) {
516 516
 			$excluded_posts_ids = array();
517 517
 		}
518 518
 
@@ -520,24 +520,24 @@  discard block
 block discarded – undo
520 520
 		$our_pages = array();
521 521
 
522 522
 		// Checkout page.
523
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
523
+		$our_pages[] = wpinv_get_option('checkout_page', false);
524 524
 
525 525
 		// Success page.
526
-		$our_pages[] = wpinv_get_option( 'success_page', false );
526
+		$our_pages[] = wpinv_get_option('success_page', false);
527 527
 
528 528
 		// Failure page.
529
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
529
+		$our_pages[] = wpinv_get_option('failure_page', false);
530 530
 
531 531
 		// History page.
532
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
532
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
533 533
 
534 534
 		// Subscriptions page.
535
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
535
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
536 536
 
537
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
537
+		$our_pages   = array_map('intval', array_filter($our_pages));
538 538
 
539 539
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
540
-		return array_unique( $excluded_posts_ids );
540
+		return array_unique($excluded_posts_ids);
541 541
 
542 542
 	}
543 543
 
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	 * @since 2.0.0
548 548
 	 */
549 549
 	public function wp_footer() {
550
-		wpinv_get_template( 'frontend-footer.php' );
550
+		wpinv_get_template('frontend-footer.php');
551 551
 	}
552 552
 
553 553
 	/**
@@ -556,14 +556,14 @@  discard block
 block discarded – undo
556 556
 	 * @since 2.0.0
557 557
 	 */
558 558
 	public function wp_head() {
559
-		wpinv_get_template( 'frontend-head.php' );
559
+		wpinv_get_template('frontend-head.php');
560 560
 	}
561 561
 
562 562
 	/**
563 563
 	 * Custom query vars.
564 564
 	 *
565 565
 	 */
566
-	public function custom_query_vars( $vars ) {
566
+	public function custom_query_vars($vars) {
567 567
         $vars[] = 'getpaid-ipn';
568 568
         return $vars;
569 569
 	}
@@ -574,28 +574,28 @@  discard block
 block discarded – undo
574 574
 	 */
575 575
 	public function add_rewrite_rule() {
576 576
         $tag = 'getpaid-ipn';
577
-        add_rewrite_tag( "%$tag%", '([^&]+)' );
578
-        add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]",'top' );
577
+        add_rewrite_tag("%$tag%", '([^&]+)');
578
+        add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top');
579 579
 	}
580 580
 
581 581
 	/**
582 582
 	 * Processes non-query string ipns.
583 583
 	 *
584 584
 	 */
585
-	public function maybe_process_new_ipn( $query ) {
585
+	public function maybe_process_new_ipn($query) {
586 586
 
587
-        if ( is_admin() || ! $query->is_main_query() ) {
587
+        if (is_admin() || !$query->is_main_query()) {
588 588
             return;
589 589
         }
590 590
 
591
-		$gateway = get_query_var( 'getpaid-ipn' );
591
+		$gateway = get_query_var('getpaid-ipn');
592 592
 
593
-        if ( ! empty( $gateway ) ){
593
+        if (!empty($gateway)) {
594 594
 
595
-			$gateway = sanitize_text_field( $gateway );
595
+			$gateway = sanitize_text_field($gateway);
596 596
 			nocache_headers();
597
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
598
-			do_action( "wpinv_verify_{$gateway}_ipn" );
597
+			do_action('wpinv_verify_payment_ipn', $gateway);
598
+			do_action("wpinv_verify_{$gateway}_ipn");
599 599
 			exit;
600 600
 
601 601
         }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-details.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Item_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the item.
@@ -270,35 +270,35 @@  discard block
 block discarded – undo
270 270
     }
271 271
 
272 272
     /**
273
-	 * Save meta box data.
274
-	 *
275
-	 * @param int $post_id
276
-	 */
277
-	public static function save( $post_id ) {
273
+     * Save meta box data.
274
+     *
275
+     * @param int $post_id
276
+     */
277
+    public static function save( $post_id ) {
278 278
 
279 279
         // Prepare the item.
280 280
         $item = new WPInv_Item( $post_id );
281 281
 
282 282
         // Load new data.
283 283
         $item->set_props(
284
-			array(
285
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
-				'is_dynamic_pricing'   => isset( $_POST['wpinv_name_your_price'] ),
284
+            array(
285
+                'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
+                'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
+                'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
+                'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
+                'is_dynamic_pricing'   => isset( $_POST['wpinv_name_your_price'] ),
290 290
                 'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
291
-				'is_recurring'         => isset( $_POST['wpinv_is_recurring'] ),
292
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
298
-			)
291
+                'is_recurring'         => isset( $_POST['wpinv_is_recurring'] ),
292
+                'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
+                'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
+                'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
+                'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
+                'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
+                'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
298
+            )
299 299
         );
300 300
 
301
-		$item->save();
302
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
303
-	}
301
+        $item->save();
302
+        do_action( 'getpaid_item_metabox_save', $post_id, $item );
303
+    }
304 304
 }
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,27 +21,27 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the item.
27
-        $item = new WPInv_Item( $post );
27
+        $item = new WPInv_Item($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
30
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
31 31
 
32 32
         // Set the currency position.
33 33
         $position = wpinv_currency_position();
34 34
 
35
-        if ( $position == 'left_space' ) {
35
+        if ($position == 'left_space') {
36 36
             $position = 'left';
37 37
         }
38 38
 
39
-        if ( $position == 'right_space' ) {
39
+        if ($position == 'right_space') {
40 40
             $position = 'right';
41 41
         }
42 42
 
43 43
         ?>
44
-        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" />
44
+        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" />
45 45
         <style>
46 46
             #poststuff .input-group-text,
47 47
             #poststuff .form-control {
@@ -55,21 +55,21 @@  discard block
 block discarded – undo
55 55
         </style>
56 56
         <div class='bsui' style='max-width: 600px;padding-top: 10px;'>
57 57
 
58
-            <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?>
58
+            <?php do_action('wpinv_item_details_metabox_before_price', $item); ?>
59 59
             <div class="form-group row">
60
-                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e( 'Item Price', 'invoicing' )?></span></label>
60
+                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php _e('Item Price', 'invoicing')?></span></label>
61 61
                 <div class="col-sm-8">
62 62
                     <div class="row">
63 63
                         <div class="col-sm-4 getpaid-price-input">
64 64
                             <div class="input-group input-group-sm">
65
-                                <?php if( 'left' == $position ) : ?>
65
+                                <?php if ('left' == $position) : ?>
66 66
                                 <div class="input-group-prepend">
67 67
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
68 68
                                 </div>
69 69
                                 <?php endif; ?>
70
-                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
70
+                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
71 71
 
72
-                                <?php if( 'left' != $position ) : ?>
72
+                                <?php if ('left' != $position) : ?>
73 73
                                 <div class="input-group-append">
74 74
                                     <span class="input-group-text" id="wpinv_item_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
75 75
                                 </div>
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
                         </div>
80 80
                         <div class="col-sm-4 wpinv_show_if_recurring">
81 81
                             <?php
82
-                                _e( 'every' );
82
+                                _e('every');
83 83
                                 echo "&nbsp;";
84 84
                             ?>
85
-                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
85
+                            <input type="number" style="max-width: 60px;" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" name="wpinv_recurring_interval" id="wpinv_recurring_interval" />
86 86
                         </div>
87 87
                         <div class="col-sm-4 wpinv_show_if_recurring">
88 88
                             <?php
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
                                     array(
91 91
                                         'id'               => 'wpinv_recurring_period',
92 92
                                         'name'             => 'wpinv_recurring_period',
93
-                                        'label'            => __( 'Period', 'invoicing' ),
94
-                                        'placeholder'      => __( 'Select Period', 'invoicing' ),
95
-                                        'value'            => $item->get_recurring_period( 'edit' ),
93
+                                        'label'            => __('Period', 'invoicing'),
94
+                                        'placeholder'      => __('Select Period', 'invoicing'),
95
+                                        'value'            => $item->get_recurring_period('edit'),
96 96
                                         'select2'          => true,
97 97
                                         'data-allow-clear' => 'false',
98 98
                                         'options'     => array(
99
-                                            'D'  => __( 'day(s)', 'invoicing' ),
100
-                                            'W'  => __( 'week(s)', 'invoicing' ),
101
-                                            'M'  => __( 'month(s)', 'invoicing' ),
102
-                                            'Y'  => __( 'year(s)', 'invoicing' ),
99
+                                            'D'  => __('day(s)', 'invoicing'),
100
+                                            'W'  => __('week(s)', 'invoicing'),
101
+                                            'M'  => __('month(s)', 'invoicing'),
102
+                                            'Y'  => __('year(s)', 'invoicing'),
103 103
                                         )
104 104
                                     )
105 105
                                 );
@@ -111,9 +111,9 @@  discard block
 block discarded – undo
111 111
                             <?php
112 112
 
113 113
                                 // Dynamic pricing.
114
-                                if( $item->supports_dynamic_pricing() ) {
114
+                                if ($item->supports_dynamic_pricing()) {
115 115
 
116
-                                    do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
116
+                                    do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item);
117 117
 
118 118
                                     // NYP toggle.
119 119
                                     echo aui()->input(
@@ -121,31 +121,31 @@  discard block
 block discarded – undo
121 121
                                             'id'          => 'wpinv_name_your_price',
122 122
                                             'name'        => 'wpinv_name_your_price',
123 123
                                             'type'        => 'checkbox',
124
-                                            'label'       => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
124
+                                            'label'       => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')),
125 125
                                             'value'       => '1',
126 126
                                             'checked'     => $item->user_can_set_their_price(),
127 127
                                             'no_wrap'     => true,
128 128
                                         )
129 129
                                     );
130 130
 
131
-                                    do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
131
+                                    do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item);
132 132
 
133 133
                                 }
134 134
 
135 135
                                 // Subscriptions.
136
-                                do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item );
136
+                                do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item);
137 137
                                 echo aui()->input(
138 138
                                     array(
139 139
                                         'id'          => 'wpinv_is_recurring',
140 140
                                         'name'        => 'wpinv_is_recurring',
141 141
                                         'type'        => 'checkbox',
142
-                                        'label'       => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ),
142
+                                        'label'       => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')),
143 143
                                         'value'       => '1',
144 144
                                         'checked'     => $item->is_recurring(),
145 145
                                         'no_wrap'     => true,
146 146
                                     )
147 147
                                 );
148
-                                do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item );
148
+                                do_action('wpinv_item_details_metabox_subscription_checkbox', $item);
149 149
 
150 150
                             ?>
151 151
                             <div class="wpinv_show_if_recurring">
@@ -155,30 +155,30 @@  discard block
 block discarded – undo
155 155
                     </div>
156 156
                 </div>
157 157
                 <div class="col-sm-1 pt-2 pl-0">
158
-                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span>
158
+                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span>
159 159
                 </div>
160 160
             </div>
161
-            <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?>
161
+            <?php do_action('wpinv_item_details_metabox_after_price', $item); ?>
162 162
 
163
-            <?php if( $item->supports_dynamic_pricing() ) : ?>
164
-                <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?>
163
+            <?php if ($item->supports_dynamic_pricing()) : ?>
164
+                <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?>
165 165
                 <div class="wpinv_show_if_dynamic wpinv_minimum_price">
166 166
 
167 167
                     <div class="form-group row">
168 168
                         <label for="wpinv_minimum_price" class="col-sm-3 col-form-label">
169
-                            <?php _e( 'Minimum Price', 'invoicing' );?>
169
+                            <?php _e('Minimum Price', 'invoicing'); ?>
170 170
                         </label>
171 171
                         <div class="col-sm-8">
172 172
                             <div class="input-group input-group-sm">
173
-                                <?php if( 'left' == $position ) : ?>
173
+                                <?php if ('left' == $position) : ?>
174 174
                                     <div class="input-group-prepend">
175 175
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
176 176
                                     </div>
177 177
                                 <?php endif; ?>
178 178
 
179
-                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
179
+                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
180 180
 
181
-                                <?php if( 'left' != $position ) : ?>
181
+                                <?php if ('left' != $position) : ?>
182 182
                                     <div class="input-group-append">
183 183
                                         <span class="input-group-text" id="wpinv_item_minimum_price_symbol"><?php echo wpinv_currency_symbol(); ?></span>
184 184
                                     </div>
@@ -187,45 +187,45 @@  discard block
 block discarded – undo
187 187
                         </div>
188 188
 
189 189
                         <div class="col-sm-1 pt-2 pl-0">
190
-                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span>
190
+                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span>
191 191
                         </div>
192 192
                     </div>
193 193
 
194 194
                 </div>
195
-                <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?>
195
+                <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?>
196 196
             <?php endif; ?>
197 197
 
198
-            <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?>
198
+            <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?>
199 199
             <div class="wpinv_show_if_recurring wpinv_maximum_renewals">
200 200
 
201 201
                 <div class="form-group row">
202 202
                     <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label">
203
-                        <?php _e( 'Maximum Renewals', 'invoicing' );?>
203
+                        <?php _e('Maximum Renewals', 'invoicing'); ?>
204 204
                     </label>
205 205
                     <div class="col-sm-8">
206
-                        <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
206
+                        <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" style="width: 100%;" />
207 207
                     </div>
208 208
                     <div class="col-sm-1 pt-2 pl-0">
209
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span>
209
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span>
210 210
                     </div>
211 211
                 </div>
212 212
 
213 213
             </div>
214
-            <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?>
214
+            <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?>
215 215
 
216
-            <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?>
216
+            <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?>
217 217
             <div class="wpinv_show_if_recurring wpinv_free_trial">
218 218
 
219 219
                 <div class="form-group row">
220
-                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e( 'Free Trial', 'invoicing' )?></label>
220
+                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php _e('Free Trial', 'invoicing')?></label>
221 221
 
222 222
                     <div class="col-sm-8">
223 223
                         <div class="row">
224 224
                             <div class="col-sm-6">
225
-                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0;?>
225
+                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?>
226 226
 
227 227
                                 <div>
228
-                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" >
228
+                                    <input type="number" name="wpinv_trial_interval" style="width: 100%;" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" >
229 229
                                 </div>
230 230
                             </div>
231 231
                             <div class="col-sm-6">
@@ -234,17 +234,17 @@  discard block
 block discarded – undo
234 234
                                         array(
235 235
                                             'id'               => 'wpinv_trial_period',
236 236
                                             'name'             => 'wpinv_trial_period',
237
-                                            'label'            => __( 'Trial Period', 'invoicing' ),
238
-                                            'placeholder'      => __( 'Trial Period', 'invoicing' ),
239
-                                            'value'            => $item->get_trial_period( 'edit' ),
237
+                                            'label'            => __('Trial Period', 'invoicing'),
238
+                                            'placeholder'      => __('Trial Period', 'invoicing'),
239
+                                            'value'            => $item->get_trial_period('edit'),
240 240
                                             'select2'          => true,
241 241
                                             'data-allow-clear' => 'false',
242 242
                                             'no_wrap'          => true,
243 243
                                             'options'          => array(
244
-                                                'D'  => __( 'day(s)', 'invoicing' ),
245
-                                                'W'  => __( 'week(s)', 'invoicing' ),
246
-                                                'M'  => __( 'month(s)', 'invoicing' ),
247
-                                                'Y'  => __( 'year(s)', 'invoicing' ),
244
+                                                'D'  => __('day(s)', 'invoicing'),
245
+                                                'W'  => __('week(s)', 'invoicing'),
246
+                                                'M'  => __('month(s)', 'invoicing'),
247
+                                                'Y'  => __('year(s)', 'invoicing'),
248 248
                                             )
249 249
                                         )
250 250
                                     );
@@ -255,15 +255,15 @@  discard block
 block discarded – undo
255 255
                     </div>
256 256
 
257 257
                     <div class="col-sm-1 pt-2 pl-0">
258
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span>
258
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span>
259 259
                     </div>
260 260
 
261 261
                 </div>
262 262
 
263 263
             </div>
264
-            <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?>
264
+            <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?>
265 265
 
266
-            <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?>
266
+            <?php do_action('wpinv_item_details_metabox_item_details', $item); ?>
267 267
         </div>
268 268
         <?php
269 269
 
@@ -274,31 +274,31 @@  discard block
 block discarded – undo
274 274
 	 *
275 275
 	 * @param int $post_id
276 276
 	 */
277
-	public static function save( $post_id ) {
277
+	public static function save($post_id) {
278 278
 
279 279
         // Prepare the item.
280
-        $item = new WPInv_Item( $post_id );
280
+        $item = new WPInv_Item($post_id);
281 281
 
282 282
         // Load new data.
283 283
         $item->set_props(
284 284
 			array(
285
-				'price'                => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
286
-				'vat_rule'             => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
287
-				'vat_class'            => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
288
-				'type'                 => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
289
-				'is_dynamic_pricing'   => isset( $_POST['wpinv_name_your_price'] ),
290
-                'minimum_price'        => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
291
-				'is_recurring'         => isset( $_POST['wpinv_is_recurring'] ),
292
-				'recurring_period'     => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
293
-				'recurring_interval'   => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
-				'recurring_limit'      => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
-				'is_free_trial'        => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
296
-				'trial_period'         => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
297
-				'trial_interval'       => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
285
+				'price'                => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null,
286
+				'vat_rule'             => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null,
287
+				'vat_class'            => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null,
288
+				'type'                 => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null,
289
+				'is_dynamic_pricing'   => isset($_POST['wpinv_name_your_price']),
290
+                'minimum_price'        => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null,
291
+				'is_recurring'         => isset($_POST['wpinv_is_recurring']),
292
+				'recurring_period'     => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null,
293
+				'recurring_interval'   => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1,
294
+				'recurring_limit'      => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null,
295
+				'is_free_trial'        => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null,
296
+				'trial_period'         => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null,
297
+				'trial_interval'       => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null,
298 298
 			)
299 299
         );
300 300
 
301 301
 		$item->save();
302
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
302
+		do_action('getpaid_item_metabox_save', $post_id, $item);
303 303
 	}
304 304
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-items.php 1 patch
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -16,78 +16,78 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class GetPaid_Meta_Box_Invoice_Items {
18 18
 
19
-    public static function get_columns( $invoice ) {
19
+    public static function get_columns($invoice) {
20 20
         $use_taxes          = $invoice->is_taxable() && wpinv_use_taxes();
21 21
         $columns            = array(
22
-            'id'     => __( 'ID', 'invoicing' ),
23
-            'title'  => __( 'Item', 'invoicing' ),
22
+            'id'     => __('ID', 'invoicing'),
23
+            'title'  => __('Item', 'invoicing'),
24 24
             'price'  => sprintf(
25 25
                 '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span>
26 26
                 <span class="getpaid-hide-if-hours hide-if-amount">%s</span>
27 27
                 <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>',
28
-                __( 'Amount', 'invoicing' ),
29
-                __( 'Price', 'invoicing' ),
30
-                __( 'Rate', 'invoicing' )
28
+                __('Amount', 'invoicing'),
29
+                __('Price', 'invoicing'),
30
+                __('Rate', 'invoicing')
31 31
             ),
32 32
             'qty'    => sprintf(
33 33
                 '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>',
34
-                __( 'Quantity', 'invoicing' ),
35
-                __( 'Hours', 'invoicing' )
34
+                __('Quantity', 'invoicing'),
35
+                __('Hours', 'invoicing')
36 36
             ),
37
-            'total'  => __( 'Total', 'invoicing' ),
38
-            'tax'    => __( 'Tax (%)', 'invoicing' ),
37
+            'total'  => __('Total', 'invoicing'),
38
+            'tax'    => __('Tax (%)', 'invoicing'),
39 39
             'action' => '',
40 40
         );
41 41
 
42
-        if ( ! $use_taxes ) {
43
-            unset( $columns['tax'] );
42
+        if (!$use_taxes) {
43
+            unset($columns['tax']);
44 44
         }
45 45
 
46 46
         return $columns;
47 47
     }
48 48
 
49
-    public static function output( $post, $invoice = false ) {
49
+    public static function output($post, $invoice = false) {
50 50
 
51
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
52
-        $invoice            = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id );
51
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
52
+        $invoice            = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id);
53 53
         $use_taxes          = $invoice->is_taxable() && wpinv_use_taxes();
54
-        $item_types         = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
55
-        $columns            = self::get_columns( $invoice );
56
-        $cols               = count( $columns );
54
+        $item_types         = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
55
+        $columns            = self::get_columns($invoice);
56
+        $cols               = count($columns);
57 57
         $class              = '';
58 58
 
59
-        unset( $item_types['adv'] );
60
-        unset( $item_types['package'] );
59
+        unset($item_types['adv']);
60
+        unset($item_types['package']);
61 61
 
62
-        if ( $invoice->is_paid() ) {
62
+        if ($invoice->is_paid()) {
63 63
             $class .= ' wpinv-paid';
64 64
         }
65 65
 
66
-        if ( $invoice->is_refunded() ) {
66
+        if ($invoice->is_refunded()) {
67 67
             $class .= ' wpinv-refunded';
68 68
         }
69 69
 
70
-        if ( $invoice->is_recurring() ) {
70
+        if ($invoice->is_recurring()) {
71 71
             $class .= ' wpi-recurring';
72 72
         }
73 73
 
74 74
     ?>
75 75
 
76
-        <div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>">
76
+        <div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>">
77 77
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
78 78
 
79 79
                 <thead>
80 80
                     <tr>
81
-                        <?php foreach ( $columns as $key => $label ) : ?>
82
-                            <th class="<?php echo esc_attr( $key ); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post( $label ); ?></th>
81
+                        <?php foreach ($columns as $key => $label) : ?>
82
+                            <th class="<?php echo esc_attr($key); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post($label); ?></th>
83 83
                         <?php endforeach; ?>
84 84
                     </tr>
85 85
                 </thead>
86 86
 
87 87
                 <tbody class="wpinv-line-items">
88 88
                     <?php
89
-                        foreach ( $invoice->get_items() as $int => $item ) {
90
-                            self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' );
89
+                        foreach ($invoice->get_items() as $int => $item) {
90
+                            self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd');
91 91
                         }
92 92
                     ?>
93 93
                 </tbody>
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
                                             <div class="wp-clearfix">
105 105
                                                 <label class="wpi-item-name">
106 106
                                                     <span class="input-text-wrap">
107
-                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
107
+                                                        <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]">
108 108
                                                     </span>
109 109
                                                 </label>
110 110
                                             </div>
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
                                             <div class="wp-clearfix">
113 113
                                                 <label class="wpi-item-price">
114 114
                                                     <span class="input-text-wrap">
115
-                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
116
-                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
115
+                                                    <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]">
116
+                                                        &times; <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]">
117 117
                                                     </span>
118 118
                                                 </label>
119 119
                                             </div>
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                                             <div class="wp-clearfix">
122 122
                                                 <label class="wpi-item-name">
123 123
                                                     <span class="input-text-wrap">
124
-                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
124
+                                                        <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea>
125 125
                                                     </span>
126 126
                                                 </label>
127 127
                                             </div>
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
                                             <div class="wp-clearfix">
130 130
                                                 <label class="wpi-item-type">
131 131
                                                     <span class="input-text-wrap">
132
-                                                        <?php echo wpinv_html_select( array(
132
+                                                        <?php echo wpinv_html_select(array(
133 133
                                                             'options'          => $item_types,
134 134
                                                             'name'             => '_wpinv_quick[type]',
135 135
                                                             'id'               => '_wpinv_quick_type',
@@ -137,19 +137,19 @@  discard block
 block discarded – undo
137 137
                                                             'show_option_all'  => false,
138 138
                                                             'show_option_none' => false,
139 139
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
140
-                                                        ) ); ?>
140
+                                                        )); ?>
141 141
                                                     </span>
142 142
                                                 </label>
143 143
                                             </div>
144 144
 
145
-                                            <?php if ( $use_taxes ) : ?>
145
+                                            <?php if ($use_taxes) : ?>
146 146
                                                 <div class="wp-clearfix">
147 147
                                                     <label class="wpi-vat-rule">
148 148
                                                         <span class="input-text-wrap">
149 149
                                                             <?php
150
-                                                                echo wpinv_html_select( array(
150
+                                                                echo wpinv_html_select(array(
151 151
                                                                     'options'          => array_merge(
152
-                                                                        array( '' => __( 'Select VAT Rule', 'invoicing' ) ),
152
+                                                                        array('' => __('Select VAT Rule', 'invoicing')),
153 153
                                                                         getpaid_get_tax_rules()
154 154
                                                                     ),
155 155
                                                                     'name'             => '_wpinv_quick[vat_rule]',
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
                                                                     'show_option_all'  => false,
158 158
                                                                     'show_option_none' => false,
159 159
                                                                     'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
160
-                                                                ) );
160
+                                                                ));
161 161
                                                             ?>
162 162
                                                         </span>
163 163
                                                     </label>
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
                                                     <label class="wpi-vat-class">
167 167
                                                         <span class="input-text-wrap">
168 168
                                                             <?php
169
-                                                                echo wpinv_html_select( array(
169
+                                                                echo wpinv_html_select(array(
170 170
                                                                     'options'          => array_merge(
171
-                                                                        array( '' => __( 'Select VAT Class', 'invoicing' ) ),
171
+                                                                        array('' => __('Select VAT Class', 'invoicing')),
172 172
                                                                         getpaid_get_tax_classes()
173 173
                                                                     ),
174 174
                                                                     'name'             => '_wpinv_quick[vat_class]',
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
                                                                     'show_option_all'  => false,
177 177
                                                                     'show_option_none' => false,
178 178
                                                                     'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
179
-                                                                ) );
179
+                                                                ));
180 180
                                                             ?>
181 181
                                                         </span>
182 182
                                                     </label>
@@ -197,29 +197,29 @@  discard block
 block discarded – undo
197 197
                         </td>
198 198
                     </tr>
199 199
                     <tr class="totals">
200
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
200
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
201 201
                         <td colspan="4">
202 202
                             <table cellspacing="0" cellpadding="0">
203 203
                                 <tr class="subtotal">
204
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
205
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td>
204
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
205
+                                    <td class="total"><?php echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td>
206 206
                                     <td class="action"></td>
207 207
                                 </tr>
208 208
                                 <tr class="discount">
209
-                                    <td class="name"><?php _e( 'Discount:', 'invoicing' ) ; ?></td>
210
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td>
209
+                                    <td class="name"><?php _e('Discount:', 'invoicing'); ?></td>
210
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td>
211 211
                                     <td class="action"></td>
212 212
                                 </tr>
213
-                                <?php if ( $use_taxes ) : ?>
213
+                                <?php if ($use_taxes) : ?>
214 214
                                 <tr class="tax">
215
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
216
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td>
215
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
216
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td>
217 217
                                     <td class="action"></td>
218 218
                                 </tr>
219 219
                                 <?php endif; ?>
220 220
                                 <tr class="total">
221
-                                    <td class="name"><?php _e( 'Total:', 'invoicing' );?></td>
222
-                                    <td class="total"><?php echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );?></td>
221
+                                    <td class="name"><?php _e('Total:', 'invoicing'); ?></td>
222
+                                    <td class="total"><?php echo wpinv_price($invoice->get_total(), $invoice->get_currency()); ?></td>
223 223
                                     <td class="action"></td>
224 224
                                 </tr>
225 225
                             </table>
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
             </table>
231 231
             <div class="wpinv-actions">
232 232
                 <?php
233
-                    if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
233
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
234 234
                         echo wpinv_item_dropdown(
235 235
                             array(
236 236
                                 'name'             => 'wpinv_invoice_item',
@@ -240,61 +240,61 @@  discard block
 block discarded – undo
240 240
                             )
241 241
                         );
242 242
 
243
-                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), $invoice->get_label() ) . '</button>';
244
-                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>';
245
-                        echo "&nbsp;" . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>';
243
+                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), $invoice->get_label()) . '</button>';
244
+                        echo "&nbsp;" . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>';
245
+                        echo "&nbsp;" . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>';
246 246
 
247 247
                     }
248 248
                 ?>
249
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
249
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
250 250
             </div>
251 251
         </div>
252 252
         <?php
253 253
     }
254 254
 
255
-    public static function output_row( $columns, $item, $invoice, $class='even' ) {
255
+    public static function output_row($columns, $item, $invoice, $class = 'even') {
256 256
 
257 257
     ?>
258
-        <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>">
259
-            <?php foreach ( array_keys( $columns ) as $column ) : ?>
260
-                <td class="<?php echo esc_attr( $column ); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>">
258
+        <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>">
259
+            <?php foreach (array_keys($columns) as $column) : ?>
260
+                <td class="<?php echo esc_attr($column); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>">
261 261
                     <?php
262
-                        switch ( $column ) {
262
+                        switch ($column) {
263 263
                             case 'id':
264 264
                                 echo (int) $item->get_id();
265 265
                                 break;
266 266
                             case 'title':
267 267
                                 printf(
268 268
                                     '<a href="%s" target="_blank">%s</a>',
269
-                                    get_edit_post_link( $item->get_id() ),
270
-                                    esc_html( $item->get_raw_name() )
269
+                                    get_edit_post_link($item->get_id()),
270
+                                    esc_html($item->get_raw_name())
271 271
                                 );
272 272
 
273
-                                $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice );
274
-                                if ( $summary !== '' ) {
273
+                                $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice);
274
+                                if ($summary !== '') {
275 275
                                     printf(
276 276
                                         '<span class="meta">%s</span>',
277
-                                        wpautop( wp_kses_post( $summary ) )
277
+                                        wpautop(wp_kses_post($summary))
278 278
                                     );
279 279
                                 }
280 280
 
281 281
                                 printf(
282 282
                                     '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />',
283
-                                    esc_attr( $item->get_raw_name() ),
283
+                                    esc_attr($item->get_raw_name()),
284 284
                                     (int) $item->get_id()
285 285
                                 );
286 286
 
287 287
                                 printf(
288 288
                                     '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>',
289 289
                                     (int) $item->get_id(),
290
-                                    esc_attr( $item->get_description() )
290
+                                    esc_attr($item->get_description())
291 291
                                 );
292 292
 
293 293
                                 break;
294 294
                             case 'price':
295 295
                                 printf(
296 296
                                     '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />',
297
-                                    esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ),
297
+                                    esc_attr(getpaid_unstandardize_amount($item->get_price())),
298 298
                                     (int) $item->get_id()
299 299
                                 );
300 300
 
@@ -302,26 +302,26 @@  discard block
 block discarded – undo
302 302
                             case 'qty':
303 303
                                 printf(
304 304
                                     '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />',
305
-                                    floatval( $item->get_quantity() ),
305
+                                    floatval($item->get_quantity()),
306 306
                                     (int) $item->get_id()
307 307
                                 );
308 308
 
309 309
                                 break;
310 310
                             case 'total':
311
-                                echo wpinv_price( $item->get_sub_total(), $invoice->get_currency() );
311
+                                echo wpinv_price($item->get_sub_total(), $invoice->get_currency());
312 312
 
313 313
                                 break;
314 314
                             case 'tax':
315
-                                echo wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%';
315
+                                echo wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%';
316 316
 
317 317
                                 break;
318 318
                             case 'action':
319
-                                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
319
+                                if (!$invoice->is_paid() && !$invoice->is_refunded()) {
320 320
                                     echo '<i class="fa fa-trash wpinv-item-remove"></i>';
321 321
                                 }
322 322
                                 break;
323 323
                         }
324
-                        do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice );
324
+                        do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice);
325 325
                     ?>
326 326
                 </td>
327 327
             <?php endforeach; ?>
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 	 *
335 335
 	 * @param WP_Post $post
336 336
 	 */
337
-    public static function output2( $post ) {
337
+    public static function output2($post) {
338 338
 
339 339
         // Prepare the invoice.
340
-        $invoice = new WPInv_Invoice( $post );
340
+        $invoice = new WPInv_Invoice($post);
341 341
 
342 342
         // Invoice items.
343 343
         $items = $invoice->get_items();
@@ -345,28 +345,28 @@  discard block
 block discarded – undo
345 345
         $totals = array(
346 346
 
347 347
             'subtotal'  => array(
348
-                'label' => __( 'Items Subtotal', 'invoicing' ),
349
-                'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
348
+                'label' => __('Items Subtotal', 'invoicing'),
349
+                'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
350 350
             ),
351 351
 
352 352
             'discount'  => array(
353
-                'label' => __( 'Total Discount', 'invoicing' ),
354
-                'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
353
+                'label' => __('Total Discount', 'invoicing'),
354
+                'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
355 355
             ),
356 356
 
357 357
             'tax'       => array(
358
-                'label' => __( 'Total Tax', 'invoicing' ),
359
-                'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
358
+                'label' => __('Total Tax', 'invoicing'),
359
+                'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
360 360
             ),
361 361
 
362 362
             'total'     => array(
363
-                'label' => __( 'Invoice Total', 'invoicing' ),
364
-                'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
363
+                'label' => __('Invoice Total', 'invoicing'),
364
+                'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
365 365
             )
366 366
         );
367 367
 
368
-        if ( ! wpinv_use_taxes() ) {
369
-            unset( $totals['tax'] );
368
+        if (!wpinv_use_taxes()) {
369
+            unset($totals['tax']);
370 370
         }
371 371
 
372 372
         $item_args = array(
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
             'orderby'        => 'title',
375 375
             'order'          => 'ASC',
376 376
             'posts_per_page' => -1,
377
-            'post_status'    => array( 'publish' ),
377
+            'post_status'    => array('publish'),
378 378
             'meta_query'     => array(
379 379
                 array(
380 380
                     'key'       => '_wpinv_type',
@@ -398,10 +398,10 @@  discard block
 block discarded – undo
398 398
             }
399 399
         </style>
400 400
 
401
-                <div class="bsui getpaid-invoice-items-inner <?php echo sanitize_html_class( $invoice->get_template( 'edit' ) ); ?> <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem">
401
+                <div class="bsui getpaid-invoice-items-inner <?php echo sanitize_html_class($invoice->get_template('edit')); ?> <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem">
402 402
 
403
-                    <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
404
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
403
+                    <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
404
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
405 405
 
406 406
                         <div class="row">
407 407
                             <div class="col-12 col-sm-6">
@@ -410,15 +410,15 @@  discard block
 block discarded – undo
410 410
                                         array(
411 411
                                             'id'          => 'wpinv_template',
412 412
                                             'name'        => 'wpinv_template',
413
-                                            'label'       => __( 'Template', 'invoicing' ),
413
+                                            'label'       => __('Template', 'invoicing'),
414 414
                                             'label_type'  => 'vertical',
415
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
415
+                                            'placeholder' => __('Choose a template', 'invoicing'),
416 416
                                             'class'       => 'form-control-sm',
417
-                                            'value'       => $invoice->get_template( 'edit' ),
417
+                                            'value'       => $invoice->get_template('edit'),
418 418
                                             'options'     => array(
419
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
420
-                                                'hours'    => __( 'Hours', 'invoicing' ),
421
-                                                'amount'   => __( 'Amount Only', 'invoicing' ),
419
+                                                'quantity' => __('Quantity', 'invoicing'),
420
+                                                'hours'    => __('Hours', 'invoicing'),
421
+                                                'amount'   => __('Amount Only', 'invoicing'),
422 422
                                             ),
423 423
                                             'data-allow-clear' => 'false',
424 424
                                             'select2'          => true,
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
                                         array(
435 435
                                             'id'          => 'wpinv_currency',
436 436
                                             'name'        => 'wpinv_currency',
437
-                                            'label'       => __( 'Currency', 'invoicing' ),
437
+                                            'label'       => __('Currency', 'invoicing'),
438 438
                                             'label_type'  => 'vertical',
439
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
439
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
440 440
                                             'class'       => 'form-control-sm',
441
-                                            'value'       => $invoice->get_currency( 'edit' ),
441
+                                            'value'       => $invoice->get_currency('edit'),
442 442
                                             'required'    => false,
443 443
                                             'data-allow-clear' => 'false',
444 444
                                             'select2'          => true,
@@ -450,24 +450,24 @@  discard block
 block discarded – undo
450 450
                             </div>
451 451
                         </div>
452 452
 
453
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
453
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
454 454
                     <?php endif; ?>
455 455
 
456 456
                     <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items">
457 457
                         <thead>
458 458
                             <tr>
459
-                                <th class="getpaid-item" colspan="2"><?php _e( 'Item', 'invoicing' ) ?></th>
459
+                                <th class="getpaid-item" colspan="2"><?php _e('Item', 'invoicing') ?></th>
460 460
                                 <th class="getpaid-quantity hide-if-amount text-right">
461
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
462
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
461
+                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
462
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
463 463
                                 </th>
464 464
                                 <th class="getpaid-price hide-if-amount text-right">
465
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Price', 'invoicing' ) ?></span>
466
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Rate', 'invoicing' ) ?></span>
465
+                                    <span class="getpaid-hide-if-hours"><?php _e('Price', 'invoicing') ?></span>
466
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Rate', 'invoicing') ?></span>
467 467
                                 </th>
468 468
                                 <th class="getpaid-item-subtotal text-right">
469
-                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e( 'Amount', 'invoicing' ) ?></span>
470
-                                    <span class="hide-if-amount"><?php _e( 'Total', 'invoicing' ) ?></span>
469
+                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e('Amount', 'invoicing') ?></span>
470
+                                    <span class="hide-if-amount"><?php _e('Total', 'invoicing') ?></span>
471 471
                                 </th>
472 472
                                 <th class="getpaid-item-actions hide-if-not-editable" width="70px">&nbsp;</th>
473 473
                             </tr>
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
 		                <tbody class="getpaid_invoice_line_items">
476 476
                             <tr class="hide-if-has-items hide-if-not-editable">
477 477
                                 <td colspan="2" class="pt-4 pb-4">
478
-                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Items', 'invoicing' ) ?></button>
479
-                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button>
478
+                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Items', 'invoicing') ?></button>
479
+                                    <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e('Create New Item', 'invoicing') ?></button>
480 480
                                 </td>
481 481
                                 <td class="hide-if-amount">&nbsp;</th>
482 482
                                 <td class="hide-if-amount">&nbsp;</th>
@@ -508,11 +508,11 @@  discard block
 block discarded – undo
508 508
                             <div class="col-12 col-sm-6 offset-sm-6">
509 509
                                 <table class="getpaid-invoice-totals text-right w-100">
510 510
                                     <tbody>
511
-                                        <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?>
512
-                                            <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>">
513
-                                                <td class="label"><?php echo sanitize_text_field( $data['label'] ) ?>:</td>
511
+                                        <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?>
512
+                                            <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>">
513
+                                                <td class="label"><?php echo sanitize_text_field($data['label']) ?>:</td>
514 514
                                                 <td width="1%"></td>
515
-                                                <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td>
515
+                                                <td class="value"><?php echo wp_kses_post($data['value']) ?></td>
516 516
                                             </tr>
517 517
                                         <?php endforeach; ?>
518 518
                                     </tbody>
@@ -525,18 +525,18 @@  discard block
 block discarded – undo
525 525
                     <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable">
526 526
                         <div class="row">
527 527
                             <div class="text-left col-12 col-sm-8">
528
-                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Item', 'invoicing' ) ?></button>
529
-                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button>
530
-                                <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?>
528
+                                <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Item', 'invoicing') ?></button>
529
+                                <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e('Create New Item', 'invoicing') ?></button>
530
+                                <?php do_action('getpaid-invoice-items-actions', $invoice); ?>
531 531
                             </div>
532 532
                             <div class="text-right col-12 col-sm-4">
533
-                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e( 'Recalculate Totals', 'invoicing' ) ?></button>
533
+                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e('Recalculate Totals', 'invoicing') ?></button>
534 534
                             </div>
535 535
                         </div>
536 536
                     </div>
537 537
 
538 538
                     <div class="getpaid-invoice-item-actions hide-if-editable">
539
-                        <p class="description m-2 text-right text-muted"><?php _e( 'This invoice is no longer editable', 'invoicing' ); ?></p>
539
+                        <p class="description m-2 text-right text-muted"><?php _e('This invoice is no longer editable', 'invoicing'); ?></p>
540 540
                     </div>
541 541
 
542 542
                     <!-- Add items to an invoice -->
@@ -544,8 +544,8 @@  discard block
 block discarded – undo
544 544
                         <div class="modal-dialog modal-dialog-centered" role="document">
545 545
                             <div class="modal-content">
546 546
                                 <div class="modal-header">
547
-                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e( "Add Item(s)", 'invoicing' ); ?></h5>
548
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
547
+                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e("Add Item(s)", 'invoicing'); ?></h5>
548
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
549 549
                                         <span aria-hidden="true">&times;</span>
550 550
                                     </button>
551 551
                                 </div>
@@ -553,10 +553,10 @@  discard block
 block discarded – undo
553 553
                                     <table class="widefat">
554 554
                                         <thead>
555 555
                                             <tr>
556
-                                                <th class="pl-0 text-left"><?php _e( 'Item', 'invoicing' ) ?></th>
556
+                                                <th class="pl-0 text-left"><?php _e('Item', 'invoicing') ?></th>
557 557
                                                 <th class="pr-0 text-right hide-if-amount">
558
-                                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
559
-                                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
558
+                                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
559
+                                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
560 560
                                                 </th>
561 561
                                             </tr>
562 562
                                         </thead>
@@ -564,9 +564,9 @@  discard block
 block discarded – undo
564 564
 								            <tr>
565 565
 									            <td class="pl-0 text-left">
566 566
                                                     <select class="regular-text getpaid-add-invoice-item-select">
567
-                                                        <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option>
568
-                                                        <?php foreach ( get_posts( $item_args ) as $item ) : ?>
569
-                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags( $item->post_title ); ?></option>
567
+                                                        <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option>
568
+                                                        <?php foreach (get_posts($item_args) as $item) : ?>
569
+                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags($item->post_title); ?></option>
570 570
                                                         <?php endforeach; ?>
571 571
                                                     </select>
572 572
                                                 </td>
@@ -578,8 +578,8 @@  discard block
 block discarded – undo
578 578
 						            </table>
579 579
                                 </div>
580 580
                                 <div class="modal-footer">
581
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
582
-                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e( 'Add', 'invoicing' ); ?></button>
581
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
582
+                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e('Add', 'invoicing'); ?></button>
583 583
                                 </div>
584 584
                             </div>
585 585
                         </div>
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
                         <div class="modal-dialog modal-dialog-centered" role="document">
591 591
                             <div class="modal-content">
592 592
                                 <div class="modal-header">
593
-                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e( "Create Item", 'invoicing' ); ?></h5>
594
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
593
+                                    <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e("Create Item", 'invoicing'); ?></h5>
594
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
595 595
                                         <span aria-hidden="true">&times;</span>
596 596
                                     </button>
597 597
                                 </div>
@@ -599,27 +599,27 @@  discard block
 block discarded – undo
599 599
                                     <div class="getpaid-create-item-div">
600 600
                                         <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id">
601 601
                                         <label class="form-group w-100">
602
-                                            <span><?php _e( 'Name', 'invoicing' ); ?></span>
603
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
602
+                                            <span><?php _e('Name', 'invoicing'); ?></span>
603
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
604 604
                                         </label>
605 605
                                         <label class="form-group w-100">
606
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span>
607
-                                            <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span>
608
-                                            <input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
606
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span>
607
+                                            <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span>
608
+                                            <input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
609 609
                                         </label>
610 610
                                         <label class="form-group w-100 hide-if-amount">
611
-                                            <span><?php _e( 'Quantity', 'invoicing' ); ?></span>
611
+                                            <span><?php _e('Quantity', 'invoicing'); ?></span>
612 612
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
613 613
                                         </label>
614 614
                                         <label class="form-group w-100">
615
-                                            <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
616
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
615
+                                            <span><?php _e('Item Description', 'invoicing'); ?></span>
616
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
617 617
                                         </label>
618 618
                                     </div>
619 619
                                 </div>
620 620
                                 <div class="modal-footer">
621
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
622
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Create', 'invoicing' ); ?></button>
621
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
622
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Create', 'invoicing'); ?></button>
623 623
                                 </div>
624 624
                             </div>
625 625
                         </div>
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
                         <div class="modal-dialog modal-dialog-centered" role="document">
631 631
                             <div class="modal-content">
632 632
                                 <div class="modal-header">
633
-                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e( "Edit Item", 'invoicing' ); ?></h5>
634
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
633
+                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e("Edit Item", 'invoicing'); ?></h5>
634
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
635 635
                                         <span aria-hidden="true">&times;</span>
636 636
                                     </button>
637 637
                                 </div>
@@ -639,27 +639,27 @@  discard block
 block discarded – undo
639 639
                                     <div class="getpaid-edit-item-div">
640 640
                                         <input type="hidden" name="id" class="form-control form-control-sm item-id">
641 641
                                         <label class="form-group w-100">
642
-                                            <span><?php _e( 'Name', 'invoicing' ); ?></span>
643
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
642
+                                            <span><?php _e('Name', 'invoicing'); ?></span>
643
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
644 644
                                         </label>
645 645
                                         <label class="form-group w-100">
646
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span>
647
-                                            <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span>
648
-                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
646
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span>
647
+                                            <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span>
648
+                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
649 649
                                         </label>
650 650
                                         <label class="form-group w-100 hide-if-amount">
651
-                                            <span><?php _e( 'Quantity', 'invoicing' ); ?></span>
651
+                                            <span><?php _e('Quantity', 'invoicing'); ?></span>
652 652
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
653 653
                                         </label>
654 654
                                         <label class="form-group w-100">
655
-                                            <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
656
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
655
+                                            <span><?php _e('Item Description', 'invoicing'); ?></span>
656
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
657 657
                                         </label>
658 658
                                     </div>
659 659
                                 </div>
660 660
                                 <div class="modal-footer">
661
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
662
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Save', 'invoicing' ); ?></button>
661
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
662
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Save', 'invoicing'); ?></button>
663 663
                                 </div>
664 664
                             </div>
665 665
                         </div>
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 1 patch
Spacing   +279 added lines, -279 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * WPInv_Ajax class.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
 	 * Hook in ajax handlers.
18 18
 	 */
19 19
 	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
20
+		add_action('init', array(__CLASS__, 'define_ajax'), 0);
21
+		add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
22 22
 		self::add_ajax_events();
23 23
     }
24 24
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	public static function define_ajax() {
29 29
 
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
30
+		if (!empty($_GET['wpinv-ajax'])) {
31
+			getpaid_maybe_define_constant('DOING_AJAX', true);
32
+			getpaid_maybe_define_constant('WPInv_DOING_AJAX', true);
33
+			if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
34
+				/** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0);
35 35
 			}
36 36
 			$GLOBALS['wpdb']->hide_errors();
37 37
 		}
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 	 * @since 1.0.18
45 45
 	 */
46 46
 	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
47
+		if (!headers_sent()) {
48 48
 			send_origin_headers();
49 49
 			send_nosniff_header();
50 50
 			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
51
+			header('Content-Type: text/html; charset=' . get_option('blog_charset'));
52
+			header('X-Robots-Tag: noindex');
53
+			status_header(200);
54 54
 		}
55 55
     }
56 56
     
@@ -60,16 +60,16 @@  discard block
 block discarded – undo
60 60
 	public static function do_wpinv_ajax() {
61 61
 		global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
63
+		if (!empty($_GET['wpinv-ajax'])) {
64
+			$wp_query->set('wpinv-ajax', sanitize_text_field(wp_unslash($_GET['wpinv-ajax'])));
65 65
 		}
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+		$action = $wp_query->get('wpinv-ajax');
68 68
 
69
-		if ( $action ) {
69
+		if ($action) {
70 70
 			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
71
+			$action = sanitize_text_field($action);
72
+			do_action('wpinv_ajax_' . $action);
73 73
 			wp_die();
74 74
 		}
75 75
 
@@ -105,36 +105,36 @@  discard block
 block discarded – undo
105 105
             'payment_form_refresh_prices' => true,
106 106
         );
107 107
 
108
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
109
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
110
-            add_action( 'wp_ajax_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
108
+        foreach ($ajax_events as $ajax_event => $nopriv) {
109
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
110
+            add_action('wp_ajax_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
111 111
 
112
-            if ( $nopriv ) {
113
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
114
-                add_action( 'wp_ajax_nopriv_getpaid_' . $ajax_event, array( __CLASS__, $ajax_event ) );
115
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
112
+            if ($nopriv) {
113
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
114
+                add_action('wp_ajax_nopriv_getpaid_' . $ajax_event, array(__CLASS__, $ajax_event));
115
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
116 116
             }
117 117
         }
118 118
     }
119 119
     
120 120
     public static function add_note() {
121
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
121
+        check_ajax_referer('add-invoice-note', '_nonce');
122 122
 
123
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
123
+        if (!wpinv_current_user_can_manage_invoicing()) {
124 124
             die(-1);
125 125
         }
126 126
 
127
-        $post_id   = absint( $_POST['post_id'] );
128
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
129
-        $note_type = sanitize_text_field( $_POST['note_type'] );
127
+        $post_id   = absint($_POST['post_id']);
128
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
129
+        $note_type = sanitize_text_field($_POST['note_type']);
130 130
 
131 131
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
132 132
 
133
-        if ( $post_id > 0 ) {
134
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
133
+        if ($post_id > 0) {
134
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
135 135
 
136
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
137
-                wpinv_get_invoice_note_line_item( $note_id );
136
+            if ($note_id > 0 && !is_wp_error($note_id)) {
137
+                wpinv_get_invoice_note_line_item($note_id);
138 138
             }
139 139
         }
140 140
 
@@ -142,16 +142,16 @@  discard block
 block discarded – undo
142 142
     }
143 143
 
144 144
     public static function delete_note() {
145
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
145
+        check_ajax_referer('delete-invoice-note', '_nonce');
146 146
 
147
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
147
+        if (!wpinv_current_user_can_manage_invoicing()) {
148 148
             die(-1);
149 149
         }
150 150
 
151
-        $note_id = (int)$_POST['note_id'];
151
+        $note_id = (int) $_POST['note_id'];
152 152
 
153
-        if ( $note_id > 0 ) {
154
-            wp_delete_comment( $note_id, true );
153
+        if ($note_id > 0) {
154
+            wp_delete_comment($note_id, true);
155 155
         }
156 156
 
157 157
         die();
@@ -169,34 +169,34 @@  discard block
 block discarded – undo
169 169
     public static function get_billing_details() {
170 170
 
171 171
         // Verify nonce.
172
-        check_ajax_referer( 'wpinv-nonce' );
172
+        check_ajax_referer('wpinv-nonce');
173 173
 
174 174
         // Can the user manage the plugin?
175
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
175
+        if (!wpinv_current_user_can_manage_invoicing()) {
176 176
             die(-1);
177 177
         }
178 178
 
179 179
         // Do we have a user id?
180 180
         $user_id = $_GET['user_id'];
181 181
 
182
-        if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
182
+        if (empty($user_id) || !is_numeric($user_id)) {
183 183
             die(-1);
184 184
         }
185 185
 
186 186
         // Fetch the billing details.
187
-        $billing_details    = wpinv_get_user_address( $user_id );
188
-        $billing_details    = apply_filters( 'wpinv_ajax_billing_details', $billing_details, $user_id );
187
+        $billing_details    = wpinv_get_user_address($user_id);
188
+        $billing_details    = apply_filters('wpinv_ajax_billing_details', $billing_details, $user_id);
189 189
 
190 190
         // unset the user id and email.
191
-        $to_ignore = array( 'user_id', 'email' );
191
+        $to_ignore = array('user_id', 'email');
192 192
 
193
-        foreach ( $to_ignore as $key ) {
194
-            if ( isset( $billing_details[ $key ] ) ) {
195
-                unset( $billing_details[ $key ] );
193
+        foreach ($to_ignore as $key) {
194
+            if (isset($billing_details[$key])) {
195
+                unset($billing_details[$key]);
196 196
             }
197 197
         }
198 198
 
199
-        wp_send_json_success( $billing_details );
199
+        wp_send_json_success($billing_details);
200 200
 
201 201
     }
202 202
 
@@ -206,47 +206,47 @@  discard block
 block discarded – undo
206 206
     public static function check_new_user_email() {
207 207
 
208 208
         // Verify nonce.
209
-        check_ajax_referer( 'wpinv-nonce' );
209
+        check_ajax_referer('wpinv-nonce');
210 210
 
211 211
         // Can the user manage the plugin?
212
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
212
+        if (!wpinv_current_user_can_manage_invoicing()) {
213 213
             die(-1);
214 214
         }
215 215
 
216 216
         // We need an email address.
217
-        if ( empty( $_GET['email'] ) ) {
218
-            _e( "Provide the new user's email address", 'invoicing' );
217
+        if (empty($_GET['email'])) {
218
+            _e("Provide the new user's email address", 'invoicing');
219 219
             exit;
220 220
         }
221 221
 
222 222
         // Ensure the email is valid.
223
-        $email = sanitize_text_field( $_GET['email'] );
224
-        if ( ! is_email( $email ) ) {
225
-            _e( 'Invalid email address', 'invoicing' );
223
+        $email = sanitize_text_field($_GET['email']);
224
+        if (!is_email($email)) {
225
+            _e('Invalid email address', 'invoicing');
226 226
             exit;
227 227
         }
228 228
 
229 229
         // And it does not exist.
230
-        $id = email_exists( $email );
231
-        if ( $id ) {
232
-            wp_send_json_success( compact( 'id' ) );
230
+        $id = email_exists($email);
231
+        if ($id) {
232
+            wp_send_json_success(compact('id'));
233 233
         }
234 234
 
235
-        wp_send_json_success( true );
235
+        wp_send_json_success(true);
236 236
     }
237 237
     
238 238
     public static function run_tool() {
239
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
240
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
239
+        check_ajax_referer('wpinv-nonce', '_nonce');
240
+        if (!wpinv_current_user_can_manage_invoicing()) {
241 241
             die(-1);
242 242
         }
243 243
         
244
-        $tool = sanitize_text_field( $_POST['tool'] );
244
+        $tool = sanitize_text_field($_POST['tool']);
245 245
         
246
-        do_action( 'wpinv_run_tool' );
246
+        do_action('wpinv_run_tool');
247 247
         
248
-        if ( !empty( $tool ) ) {
249
-            do_action( 'wpinv_tool_' . $tool );
248
+        if (!empty($tool)) {
249
+            do_action('wpinv_tool_' . $tool);
250 250
         }
251 251
     }
252 252
 
@@ -256,27 +256,27 @@  discard block
 block discarded – undo
256 256
     public static function get_payment_form() {
257 257
 
258 258
         // Check nonce.
259
-        check_ajax_referer( 'getpaid_form_nonce' );
259
+        check_ajax_referer('getpaid_form_nonce');
260 260
 
261 261
         // Is the request set up correctly?
262
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
262
+		if (empty($_GET['form']) && empty($_GET['item'])) {
263 263
 			echo aui()->alert(
264 264
 				array(
265 265
 					'type'    => 'warning',
266
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
266
+					'content' => __('No payment form or item provided', 'invoicing'),
267 267
 				)
268 268
             );
269 269
             exit;
270 270
         }
271 271
 
272 272
         // Payment form or button?
273
-		if ( ! empty( $_GET['form'] ) ) {
274
-            getpaid_display_payment_form( urldecode( $_GET['form'] ) );
275
-		} else if( ! empty( $_GET['invoice'] ) ) {
276
-		    getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) );
273
+		if (!empty($_GET['form'])) {
274
+            getpaid_display_payment_form(urldecode($_GET['form']));
275
+		} else if (!empty($_GET['invoice'])) {
276
+		    getpaid_display_invoice_payment_form(urldecode($_GET['invoice']));
277 277
         } else {
278
-			$items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) );
279
-		    getpaid_display_item_payment_form( $items );
278
+			$items = getpaid_convert_items_to_array(urldecode($_GET['item']));
279
+		    getpaid_display_item_payment_form($items);
280 280
         }
281 281
 
282 282
         exit;
@@ -291,17 +291,17 @@  discard block
 block discarded – undo
291 291
     public static function payment_form() {
292 292
 
293 293
         // Check nonce.
294
-        check_ajax_referer( 'getpaid_form_nonce' );
294
+        check_ajax_referer('getpaid_form_nonce');
295 295
 
296 296
         // ... form fields...
297
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
298
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
297
+        if (empty($_POST['getpaid_payment_form_submission'])) {
298
+            _e('Error: Reload the page and try again.', 'invoicing');
299 299
             exit;
300 300
         }
301 301
 
302 302
         // Process the payment form.
303
-        $checkout_class = apply_filters( 'getpaid_checkout_class', 'GetPaid_Checkout' );
304
-        $checkout       = new $checkout_class( new GetPaid_Payment_Form_Submission() );
303
+        $checkout_class = apply_filters('getpaid_checkout_class', 'GetPaid_Checkout');
304
+        $checkout       = new $checkout_class(new GetPaid_Payment_Form_Submission());
305 305
         $checkout->process_checkout();
306 306
 
307 307
         exit;
@@ -314,55 +314,55 @@  discard block
 block discarded – undo
314 314
      */
315 315
     public static function get_payment_form_states_field() {
316 316
 
317
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
317
+        if (empty($_GET['country']) || empty($_GET['form'])) {
318 318
             exit;
319 319
         }
320 320
 
321
-        $elements = getpaid_get_payment_form_elements( $_GET['form'] );
321
+        $elements = getpaid_get_payment_form_elements($_GET['form']);
322 322
 
323
-        if ( empty( $elements ) ) {
323
+        if (empty($elements)) {
324 324
             exit;
325 325
         }
326 326
 
327 327
         $address_fields = array();
328
-        foreach ( $elements as $element ) {
329
-            if ( 'address' === $element['type'] ) {
328
+        foreach ($elements as $element) {
329
+            if ('address' === $element['type']) {
330 330
                 $address_fields = $element;
331 331
                 break;
332 332
             }
333 333
         }
334 334
 
335
-        if ( empty( $address_fields ) ) {
335
+        if (empty($address_fields)) {
336 336
             exit;
337 337
         }
338 338
 
339
-        foreach ( $address_fields['fields'] as $address_field ) {
339
+        foreach ($address_fields['fields'] as $address_field) {
340 340
 
341
-            if ( 'wpinv_state' == $address_field['name'] ) {
341
+            if ('wpinv_state' == $address_field['name']) {
342 342
 
343
-                $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
344
-                $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
345
-                $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
346
-                $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
347
-                $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_state', true ) : '';
348
-                $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
343
+                $wrap_class  = getpaid_get_form_element_grid_class($address_field);
344
+                $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
345
+                $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
346
+                $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
347
+                $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_state', true) : '';
348
+                $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
349 349
 
350
-                if ( ! empty( $address_field['required'] ) ) {
350
+                if (!empty($address_field['required'])) {
351 351
                     $label .= "<span class='text-danger'> *</span>";
352 352
                 }
353 353
 
354
-                $html = getpaid_get_states_select_markup (
355
-                    sanitize_text_field( $_GET['country'] ),
354
+                $html = getpaid_get_states_select_markup(
355
+                    sanitize_text_field($_GET['country']),
356 356
                     $value,
357 357
                     $placeholder,
358 358
                     $label,
359 359
                     $description,
360
-                    ! empty( $address_field['required'] ),
360
+                    !empty($address_field['required']),
361 361
                     $wrap_class,
362
-                    wpinv_clean( $_GET['name'] )
362
+                    wpinv_clean($_GET['name'])
363 363
                 );
364 364
 
365
-                wp_send_json_success( $html );
365
+                wp_send_json_success($html);
366 366
                 exit;
367 367
 
368 368
             }
@@ -378,66 +378,66 @@  discard block
 block discarded – undo
378 378
     public static function recalculate_invoice_totals() {
379 379
 
380 380
         // Verify nonce.
381
-        check_ajax_referer( 'wpinv-nonce' );
381
+        check_ajax_referer('wpinv-nonce');
382 382
 
383
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
383
+        if (!wpinv_current_user_can_manage_invoicing()) {
384 384
             exit;
385 385
         }
386 386
 
387 387
         // We need an invoice.
388
-        if ( empty( $_POST['post_id'] ) ) {
388
+        if (empty($_POST['post_id'])) {
389 389
             exit;
390 390
         }
391 391
 
392 392
         // Fetch the invoice.
393
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
393
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
394 394
 
395 395
         // Ensure it exists.
396
-        if ( ! $invoice->get_id() ) {
396
+        if (!$invoice->get_id()) {
397 397
             exit;
398 398
         }
399 399
 
400 400
         // Maybe set the country, state, currency.
401
-        foreach ( array( 'country', 'state', 'currency', 'vat_number', 'discount_code' ) as $key ) {
402
-            if ( isset( $_POST[ $key ] ) ) {
401
+        foreach (array('country', 'state', 'currency', 'vat_number', 'discount_code') as $key) {
402
+            if (isset($_POST[$key])) {
403 403
                 $method = "set_$key";
404
-                $invoice->$method( sanitize_text_field( $_POST[ $key ] ) );
404
+                $invoice->$method(sanitize_text_field($_POST[$key]));
405 405
             }
406 406
         }
407 407
 
408 408
         // Maybe disable taxes.
409
-        $invoice->set_disable_taxes( ! empty( $_POST['taxes'] ) );
409
+        $invoice->set_disable_taxes(!empty($_POST['taxes']));
410 410
 
411 411
         // Discount code.
412
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
413
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
414
-            if ( $discount->exists() ) {
415
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
412
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
413
+            $discount = new WPInv_Discount($invoice->get_discount_code());
414
+            if ($discount->exists()) {
415
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
416 416
             } else {
417
-                $invoice->remove_discount( 'discount_code' );
417
+                $invoice->remove_discount('discount_code');
418 418
             }
419 419
         }
420 420
 
421 421
         // Recalculate totals.
422 422
         $invoice->recalculate_total();
423 423
 
424
-        $total        = wpinv_price( $invoice->get_total(), $invoice->get_currency() );
425
-        $suscriptions = getpaid_get_invoice_subscriptions( $invoice );
426
-        if ( is_a( $suscriptions, 'WPInv_Subscription' ) && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total() ) {
427
-            $recurring_total = wpinv_price( $invoice->get_recurring_total(), $invoice->get_currency() );
428
-            $total          .= '<small class="form-text text-muted">' . sprintf( __( 'Recurring Price: %s', 'invoicing' ), $recurring_total ) . '</small>';
424
+        $total        = wpinv_price($invoice->get_total(), $invoice->get_currency());
425
+        $suscriptions = getpaid_get_invoice_subscriptions($invoice);
426
+        if (is_a($suscriptions, 'WPInv_Subscription') && $invoice->is_recurring() && $invoice->is_parent() && $invoice->get_total() != $invoice->get_recurring_total()) {
427
+            $recurring_total = wpinv_price($invoice->get_recurring_total(), $invoice->get_currency());
428
+            $total          .= '<small class="form-text text-muted">' . sprintf(__('Recurring Price: %s', 'invoicing'), $recurring_total) . '</small>';
429 429
         }
430 430
 
431 431
         $totals = array(
432
-            'subtotal' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
433
-            'discount' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
434
-            'tax'      => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
432
+            'subtotal' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
433
+            'discount' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
434
+            'tax'      => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
435 435
             'total'    => $total,
436 436
         );
437 437
 
438
-        $totals = apply_filters( 'getpaid_invoice_totals', $totals, $invoice );
438
+        $totals = apply_filters('getpaid_invoice_totals', $totals, $invoice);
439 439
 
440
-        wp_send_json_success( compact( 'totals' ) );
440
+        wp_send_json_success(compact('totals'));
441 441
     }
442 442
 
443 443
     /**
@@ -446,33 +446,33 @@  discard block
 block discarded – undo
446 446
     public static function get_invoice_items() {
447 447
 
448 448
         // Verify nonce.
449
-        check_ajax_referer( 'wpinv-nonce' );
449
+        check_ajax_referer('wpinv-nonce');
450 450
 
451
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
451
+        if (!wpinv_current_user_can_manage_invoicing()) {
452 452
             exit;
453 453
         }
454 454
 
455 455
         // We need an invoice and items.
456
-        if ( empty( $_POST['post_id'] ) ) {
456
+        if (empty($_POST['post_id'])) {
457 457
             exit;
458 458
         }
459 459
 
460 460
         // Fetch the invoice.
461
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
461
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
462 462
 
463 463
         // Ensure it exists.
464
-        if ( ! $invoice->get_id() ) {
464
+        if (!$invoice->get_id()) {
465 465
             exit;
466 466
         }
467 467
 
468 468
         // Return an array of invoice items.
469 469
         $items = array();
470 470
 
471
-        foreach ( $invoice->get_items() as $item ) {
472
-            $items[] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency(), $invoice->is_renewal()  );
471
+        foreach ($invoice->get_items() as $item) {
472
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency(), $invoice->is_renewal());
473 473
         }
474 474
 
475
-        wp_send_json_success( compact( 'items' ) );
475
+        wp_send_json_success(compact('items'));
476 476
     }
477 477
 
478 478
     /**
@@ -481,50 +481,50 @@  discard block
 block discarded – undo
481 481
     public static function edit_invoice_item() {
482 482
 
483 483
         // Verify nonce.
484
-        check_ajax_referer( 'wpinv-nonce' );
484
+        check_ajax_referer('wpinv-nonce');
485 485
 
486
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
486
+        if (!wpinv_current_user_can_manage_invoicing()) {
487 487
             exit;
488 488
         }
489 489
 
490 490
         // We need an invoice and item details.
491
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['data'] ) ) {
491
+        if (empty($_POST['post_id']) || empty($_POST['data'])) {
492 492
             exit;
493 493
         }
494 494
 
495 495
         // Fetch the invoice.
496
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
496
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
497 497
 
498 498
         // Ensure it exists and its not been paid for.
499
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
499
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
500 500
             exit;
501 501
         }
502 502
 
503 503
         // Format the data.
504
-        $data = wp_unslash( wp_list_pluck( $_POST['data'], 'value', 'field' ) );
504
+        $data = wp_unslash(wp_list_pluck($_POST['data'], 'value', 'field'));
505 505
 
506 506
         // Ensure that we have an item id.
507
-        if ( empty( $data['id'] ) ) {
507
+        if (empty($data['id'])) {
508 508
             exit;
509 509
         }
510 510
 
511 511
         // Abort if the invoice does not have the specified item.
512
-        $item = $invoice->get_item( (int) $data['id'] );
512
+        $item = $invoice->get_item((int) $data['id']);
513 513
 
514
-        if ( empty( $item ) ) {
514
+        if (empty($item)) {
515 515
             exit;
516 516
         }
517 517
 
518 518
         // Update the item.
519
-        $item->set_price( getpaid_standardize_amount( $data['price'] ) );
520
-        $item->set_name( sanitize_text_field( $data['name'] ) );
521
-        $item->set_description( wp_kses_post( $data['description'] ) );
522
-        $item->set_quantity( floatval( $data['quantity'] ) );
519
+        $item->set_price(getpaid_standardize_amount($data['price']));
520
+        $item->set_name(sanitize_text_field($data['name']));
521
+        $item->set_description(wp_kses_post($data['description']));
522
+        $item->set_quantity(floatval($data['quantity']));
523 523
 
524 524
         // Add it to the invoice.
525
-        $error = $invoice->add_item( $item );
525
+        $error = $invoice->add_item($item);
526 526
         $alert = false;
527
-        if ( is_wp_error( $error ) ) {
527
+        if (is_wp_error($error)) {
528 528
             $alert = $error->get_error_message();
529 529
         }
530 530
 
@@ -537,11 +537,11 @@  discard block
 block discarded – undo
537 537
         // Return an array of invoice items.
538 538
         $items = array();
539 539
 
540
-        foreach ( $invoice->get_items() as $item ) {
541
-            $items[] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
540
+        foreach ($invoice->get_items() as $item) {
541
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
542 542
         }
543 543
 
544
-        wp_send_json_success( compact( 'items', 'alert' ) );
544
+        wp_send_json_success(compact('items', 'alert'));
545 545
     }
546 546
 
547 547
     /**
@@ -550,53 +550,53 @@  discard block
 block discarded – undo
550 550
     public static function create_invoice_item() {
551 551
 
552 552
         // Verify nonce.
553
-        check_ajax_referer( 'wpinv-nonce' );
553
+        check_ajax_referer('wpinv-nonce');
554 554
 
555
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
555
+        if (!wpinv_current_user_can_manage_invoicing()) {
556 556
             exit;
557 557
         }
558 558
 
559 559
         // We need an invoice and item details.
560
-        if ( empty( $_POST['invoice_id'] ) || empty( $_POST['_wpinv_quick'] ) ) {
560
+        if (empty($_POST['invoice_id']) || empty($_POST['_wpinv_quick'])) {
561 561
             exit;
562 562
         }
563 563
 
564 564
         // Fetch the invoice.
565
-        $invoice = new WPInv_Invoice( trim( $_POST['invoice_id'] ) );
565
+        $invoice = new WPInv_Invoice(trim($_POST['invoice_id']));
566 566
 
567 567
         // Ensure it exists and its not been paid for.
568
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
568
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
569 569
             exit;
570 570
         }
571 571
 
572 572
         // Format the data.
573
-        $data = wp_unslash( $_POST['_wpinv_quick'] );
573
+        $data = wp_unslash($_POST['_wpinv_quick']);
574 574
 
575 575
         $item = new WPInv_Item();
576
-        $item->set_price( getpaid_standardize_amount( $data['price'] ) );
577
-        $item->set_name( sanitize_text_field( $data['name'] ) );
578
-        $item->set_description( wp_kses_post( $data['description'] ) );
579
-        $item->set_type( sanitize_text_field( $data['type'] ) );
580
-        $item->set_vat_rule( sanitize_text_field( $data['vat_rule'] ) );
581
-        $item->set_vat_class( sanitize_text_field( $data['vat_class'] ) );
582
-        $item->set_status( 'publish' );
576
+        $item->set_price(getpaid_standardize_amount($data['price']));
577
+        $item->set_name(sanitize_text_field($data['name']));
578
+        $item->set_description(wp_kses_post($data['description']));
579
+        $item->set_type(sanitize_text_field($data['type']));
580
+        $item->set_vat_rule(sanitize_text_field($data['vat_rule']));
581
+        $item->set_vat_class(sanitize_text_field($data['vat_class']));
582
+        $item->set_status('publish');
583 583
         $item->save();
584 584
 
585
-        if ( ! $item->exists() ) {
586
-            $alert = __( 'Could not create invoice item. Please try again.', 'invoicing' );
587
-            wp_send_json_success( compact( 'alert' ) );
585
+        if (!$item->exists()) {
586
+            $alert = __('Could not create invoice item. Please try again.', 'invoicing');
587
+            wp_send_json_success(compact('alert'));
588 588
         }
589 589
 
590
-        $item = new GetPaid_Form_Item( $item->get_id() );
591
-        $item->set_quantity( floatval( $data['qty'] ) );
590
+        $item = new GetPaid_Form_Item($item->get_id());
591
+        $item->set_quantity(floatval($data['qty']));
592 592
 
593 593
         // Add it to the invoice.
594
-        $error = $invoice->add_item( $item );
594
+        $error = $invoice->add_item($item);
595 595
         $alert = false;
596 596
 
597
-        if ( is_wp_error( $error ) ) {
597
+        if (is_wp_error($error)) {
598 598
             $alert = $error->get_error_message();
599
-            wp_send_json_success( compact( 'alert' ) );
599
+            wp_send_json_success(compact('alert'));
600 600
          }
601 601
 
602 602
         // Update totals.
@@ -609,9 +609,9 @@  discard block
 block discarded – undo
609 609
         $invoice->recalculate_total();
610 610
         $invoice->save();
611 611
         ob_start();
612
-        GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice );
612
+        GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice);
613 613
         $row = ob_get_clean();
614
-        wp_send_json_success( compact( 'row' ) );
614
+        wp_send_json_success(compact('row'));
615 615
     }
616 616
 
617 617
     /**
@@ -620,33 +620,33 @@  discard block
 block discarded – undo
620 620
     public static function remove_invoice_item() {
621 621
 
622 622
         // Verify nonce.
623
-        check_ajax_referer( 'wpinv-nonce' );
623
+        check_ajax_referer('wpinv-nonce');
624 624
 
625
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
625
+        if (!wpinv_current_user_can_manage_invoicing()) {
626 626
             exit;
627 627
         }
628 628
 
629 629
         // We need an invoice and an item.
630
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
630
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
631 631
             exit;
632 632
         }
633 633
 
634 634
         // Fetch the invoice.
635
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
635
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
636 636
 
637 637
         // Ensure it exists and its not been paid for.
638
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
638
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
639 639
             exit;
640 640
         }
641 641
 
642 642
         // Abort if the invoice does not have the specified item.
643
-        $item = $invoice->get_item( (int) $_POST['item_id'] );
643
+        $item = $invoice->get_item((int) $_POST['item_id']);
644 644
 
645
-        if ( empty( $item ) ) {
645
+        if (empty($item)) {
646 646
             exit;
647 647
         }
648 648
 
649
-        $invoice->remove_item( (int) $_POST['item_id'] );
649
+        $invoice->remove_item((int) $_POST['item_id']);
650 650
 
651 651
         // Update totals.
652 652
         $invoice->recalculate_total();
@@ -657,11 +657,11 @@  discard block
 block discarded – undo
657 657
         // Return an array of invoice items.
658 658
         $items = array();
659 659
 
660
-        foreach ( $invoice->get_items() as $item ) {
661
-            $items[] = $item->prepare_data_for_invoice_edit_ajax(  $invoice->get_currency()  );
660
+        foreach ($invoice->get_items() as $item) {
661
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
662 662
         }
663 663
 
664
-        wp_send_json_success( compact( 'items' ) );
664
+        wp_send_json_success(compact('items'));
665 665
     }
666 666
 
667 667
     /**
@@ -670,69 +670,69 @@  discard block
 block discarded – undo
670 670
     public static function recalculate_full_prices() {
671 671
 
672 672
         // Verify nonce.
673
-        check_ajax_referer( 'wpinv-nonce' );
673
+        check_ajax_referer('wpinv-nonce');
674 674
 
675
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
675
+        if (!wpinv_current_user_can_manage_invoicing()) {
676 676
             exit;
677 677
         }
678 678
 
679 679
         // We need an invoice and item.
680
-        if ( empty( $_POST['post_id'] ) ) {
680
+        if (empty($_POST['post_id'])) {
681 681
             exit;
682 682
         }
683 683
 
684 684
         // Fetch the invoice.
685
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
685
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
686 686
         $alert   = false;
687 687
 
688 688
         // Ensure it exists and its not been paid for.
689
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
689
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
690 690
             exit;
691 691
         }
692 692
 
693
-        $invoice->set_items( array() );
693
+        $invoice->set_items(array());
694 694
 
695
-        if ( ! empty( $_POST['getpaid_items'] ) ) {
695
+        if (!empty($_POST['getpaid_items'])) {
696 696
 
697
-            foreach ( $_POST['getpaid_items'] as $item_id => $args ) {
698
-                $item = new GetPaid_Form_Item( $item_id );
697
+            foreach ($_POST['getpaid_items'] as $item_id => $args) {
698
+                $item = new GetPaid_Form_Item($item_id);
699 699
 
700
-                if ( $item->exists() ) {
701
-                    $item->set_price( getpaid_standardize_amount( $args['price'] ) );
702
-                    $item->set_quantity( floatval( $args['quantity'] ) );
703
-                    $item->set_name( sanitize_text_field( $args['name'] ) );
704
-                    $item->set_description( wp_kses_post( $args['description'] ) );
705
-                    $invoice->add_item( $item );
700
+                if ($item->exists()) {
701
+                    $item->set_price(getpaid_standardize_amount($args['price']));
702
+                    $item->set_quantity(floatval($args['quantity']));
703
+                    $item->set_name(sanitize_text_field($args['name']));
704
+                    $item->set_description(wp_kses_post($args['description']));
705
+                    $invoice->add_item($item);
706 706
                 }
707 707
             }
708 708
 
709 709
         }
710 710
 
711
-        $invoice->set_disable_taxes( ! empty( $_POST['disable_taxes'] ) );
711
+        $invoice->set_disable_taxes(!empty($_POST['disable_taxes']));
712 712
 
713 713
         // Maybe set the country, state, currency.
714
-        foreach ( array( 'wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code' ) as $key ) {
715
-            if ( isset( $_POST[ $key ] ) ) {
716
-                $_key   = str_replace( 'wpinv_', '', $key );
714
+        foreach (array('wpinv_country', 'wpinv_state', 'wpinv_currency', 'wpinv_vat_number', 'wpinv_discount_code') as $key) {
715
+            if (isset($_POST[$key])) {
716
+                $_key   = str_replace('wpinv_', '', $key);
717 717
                 $method = "set_$_key";
718
-                $invoice->$method( sanitize_text_field( $_POST[ $key ] ) );
718
+                $invoice->$method(sanitize_text_field($_POST[$key]));
719 719
             }
720 720
         }
721 721
 
722
-        $discount = new WPInv_Discount( $invoice->get_discount_code() );
723
-        if ( $discount->exists() ) {
724
-            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
722
+        $discount = new WPInv_Discount($invoice->get_discount_code());
723
+        if ($discount->exists()) {
724
+            $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
725 725
         } else {
726
-            $invoice->remove_discount( 'discount_code' );
726
+            $invoice->remove_discount('discount_code');
727 727
         }
728 728
 
729 729
         // Save the invoice.
730 730
         $invoice->recalculate_total();
731 731
         $invoice->save();
732 732
         ob_start();
733
-        GetPaid_Meta_Box_Invoice_Items::output( get_post( $invoice->get_id() ), $invoice );
733
+        GetPaid_Meta_Box_Invoice_Items::output(get_post($invoice->get_id()), $invoice);
734 734
         $table = ob_get_clean();
735
-        wp_send_json_success( compact( 'table' ) );
735
+        wp_send_json_success(compact('table'));
736 736
     }
737 737
 
738 738
     /**
@@ -741,42 +741,42 @@  discard block
 block discarded – undo
741 741
     public static function admin_add_invoice_item() {
742 742
 
743 743
         // Verify nonce.
744
-        check_ajax_referer( 'wpinv-nonce' );
744
+        check_ajax_referer('wpinv-nonce');
745 745
 
746
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
746
+        if (!wpinv_current_user_can_manage_invoicing()) {
747 747
             exit;
748 748
         }
749 749
 
750 750
         // We need an invoice and item.
751
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['item_id'] ) ) {
751
+        if (empty($_POST['post_id']) || empty($_POST['item_id'])) {
752 752
             exit;
753 753
         }
754 754
 
755 755
         // Fetch the invoice.
756
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
756
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
757 757
         $alert   = false;
758 758
 
759 759
         // Ensure it exists and its not been paid for.
760
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
760
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
761 761
             exit;
762 762
         }
763 763
 
764 764
         // Add the item.
765
-        $item  = new GetPaid_Form_Item( (int) $_POST['item_id'] );
766
-        $error = $invoice->add_item( $item );
765
+        $item  = new GetPaid_Form_Item((int) $_POST['item_id']);
766
+        $error = $invoice->add_item($item);
767 767
 
768
-        if ( is_wp_error( $error ) ) {
768
+        if (is_wp_error($error)) {
769 769
             $alert = $error->get_error_message();
770
-            wp_send_json_success( compact( 'alert' ) );
770
+            wp_send_json_success(compact('alert'));
771 771
         }
772 772
 
773 773
         // Save the invoice.
774 774
         $invoice->recalculate_total();
775 775
         $invoice->save();
776 776
         ob_start();
777
-        GetPaid_Meta_Box_Invoice_Items::output_row( GetPaid_Meta_Box_Invoice_Items::get_columns( $invoice ), $item, $invoice );
777
+        GetPaid_Meta_Box_Invoice_Items::output_row(GetPaid_Meta_Box_Invoice_Items::get_columns($invoice), $item, $invoice);
778 778
         $row = ob_get_clean();
779
-        wp_send_json_success( compact( 'row' ) );
779
+        wp_send_json_success(compact('row'));
780 780
     }
781 781
 
782 782
     /**
@@ -785,39 +785,39 @@  discard block
 block discarded – undo
785 785
     public static function add_invoice_items() {
786 786
 
787 787
         // Verify nonce.
788
-        check_ajax_referer( 'wpinv-nonce' );
788
+        check_ajax_referer('wpinv-nonce');
789 789
 
790
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
790
+        if (!wpinv_current_user_can_manage_invoicing()) {
791 791
             exit;
792 792
         }
793 793
 
794 794
         // We need an invoice and items.
795
-        if ( empty( $_POST['post_id'] ) || empty( $_POST['items'] ) ) {
795
+        if (empty($_POST['post_id']) || empty($_POST['items'])) {
796 796
             exit;
797 797
         }
798 798
 
799 799
         // Fetch the invoice.
800
-        $invoice = new WPInv_Invoice( trim( $_POST['post_id'] ) );
800
+        $invoice = new WPInv_Invoice(trim($_POST['post_id']));
801 801
         $alert   = false;
802 802
 
803 803
         // Ensure it exists and its not been paid for.
804
-        if ( ! $invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded() ) {
804
+        if (!$invoice->get_id() || $invoice->is_paid() || $invoice->is_refunded()) {
805 805
             exit;
806 806
         }
807 807
 
808 808
         // Add the items.
809
-        foreach ( $_POST['items'] as $data ) {
809
+        foreach ($_POST['items'] as $data) {
810 810
 
811
-            $item = new GetPaid_Form_Item( $data[ 'id' ] );
811
+            $item = new GetPaid_Form_Item($data['id']);
812 812
 
813
-            if ( is_numeric( $data[ 'qty' ] ) && (float) $data[ 'qty' ] > 0 ) {
814
-                $item->set_quantity( $data[ 'qty' ] );
813
+            if (is_numeric($data['qty']) && (float) $data['qty'] > 0) {
814
+                $item->set_quantity($data['qty']);
815 815
             }
816 816
 
817
-            if ( $item->get_id() > 0 ) {
818
-                $error = $invoice->add_item( $item );
817
+            if ($item->get_id() > 0) {
818
+                $error = $invoice->add_item($item);
819 819
 
820
-                if ( is_wp_error( $error ) ) {
820
+                if (is_wp_error($error)) {
821 821
                     $alert = $error->get_error_message();
822 822
                 }
823 823
 
@@ -832,11 +832,11 @@  discard block
 block discarded – undo
832 832
         // Return an array of invoice items.
833 833
         $items = array();
834 834
 
835
-        foreach ( $invoice->get_items() as $item ) {
836
-            $items[] = $item->prepare_data_for_invoice_edit_ajax( $invoice->get_currency() );
835
+        foreach ($invoice->get_items() as $item) {
836
+            $items[] = $item->prepare_data_for_invoice_edit_ajax($invoice->get_currency());
837 837
         }
838 838
 
839
-        wp_send_json_success( compact( 'items', 'alert' ) );
839
+        wp_send_json_success(compact('items', 'alert'));
840 840
     }
841 841
 
842 842
     /**
@@ -845,15 +845,15 @@  discard block
 block discarded – undo
845 845
     public static function get_invoicing_items() {
846 846
 
847 847
         // Verify nonce.
848
-        check_ajax_referer( 'wpinv-nonce' );
848
+        check_ajax_referer('wpinv-nonce');
849 849
 
850
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
850
+        if (!wpinv_current_user_can_manage_invoicing()) {
851 851
             exit;
852 852
         }
853 853
 
854 854
         // We need a search term.
855
-        if ( empty( $_GET['search'] ) ) {
856
-            wp_send_json_success( array() );
855
+        if (empty($_GET['search'])) {
856
+            wp_send_json_success(array());
857 857
         }
858 858
 
859 859
         // Retrieve items.
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
             'orderby'        => 'title',
863 863
             'order'          => 'ASC',
864 864
             'posts_per_page' => -1,
865
-            'post_status'    => array( 'publish' ),
866
-            's'              => trim( $_GET['search'] ),
865
+            'post_status'    => array('publish'),
866
+            's'              => trim($_GET['search']),
867 867
             'meta_query'     => array(
868 868
                 array(
869 869
                     'key'       => '_wpinv_type',
@@ -873,21 +873,21 @@  discard block
 block discarded – undo
873 873
             )
874 874
         );
875 875
 
876
-        $items = get_posts( apply_filters( 'getpaid_ajax_invoice_items_query_args', $item_args ) );
876
+        $items = get_posts(apply_filters('getpaid_ajax_invoice_items_query_args', $item_args));
877 877
         $data  = array();
878 878
 
879
-        $is_payment_form = ( ! empty( $_GET['post_id'] ) && 'wpi_payment_form' == get_post_type( $_GET['post_id'] ) );
879
+        $is_payment_form = (!empty($_GET['post_id']) && 'wpi_payment_form' == get_post_type($_GET['post_id']));
880 880
 
881
-        foreach ( $items as $item ) {
882
-            $item      = new GetPaid_Form_Item( $item );
881
+        foreach ($items as $item) {
882
+            $item = new GetPaid_Form_Item($item);
883 883
             $data[] = array(
884 884
                 'id'        => (int) $item->get_id(),
885
-                'text'      => strip_tags( $item->get_name() ),
886
-                'form_data' => $is_payment_form ? $item->prepare_data_for_use( false ) : '',
885
+                'text'      => strip_tags($item->get_name()),
886
+                'form_data' => $is_payment_form ? $item->prepare_data_for_use(false) : '',
887 887
             );
888 888
         }
889 889
 
890
-        wp_send_json_success( $data );
890
+        wp_send_json_success($data);
891 891
 
892 892
     }
893 893
 
@@ -897,37 +897,37 @@  discard block
 block discarded – undo
897 897
     public static function get_customers() {
898 898
 
899 899
         // Verify nonce.
900
-        check_ajax_referer( 'wpinv-nonce' );
900
+        check_ajax_referer('wpinv-nonce');
901 901
 
902
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
902
+        if (!wpinv_current_user_can_manage_invoicing()) {
903 903
             exit;
904 904
         }
905 905
 
906 906
         // We need a search term.
907
-        if ( empty( $_GET['search'] ) ) {
908
-            wp_send_json_success( array() );
907
+        if (empty($_GET['search'])) {
908
+            wp_send_json_success(array());
909 909
         }
910 910
 
911 911
         // Retrieve customers.
912 912
     
913 913
         $customer_args = array(
914
-            'fields'         => array( 'ID', 'user_email', 'display_name' ),
914
+            'fields'         => array('ID', 'user_email', 'display_name'),
915 915
             'orderby'        => 'display_name',
916
-            'search'         => '*' . sanitize_text_field( $_GET['search'] ) . '*',
917
-            'search_columns' => array( 'user_login', 'user_email', 'display_name' ),
916
+            'search'         => '*' . sanitize_text_field($_GET['search']) . '*',
917
+            'search_columns' => array('user_login', 'user_email', 'display_name'),
918 918
         );
919 919
 
920
-        $customers = get_users( apply_filters( 'getpaid_ajax_invoice_customers_query_args', $customer_args ) );
920
+        $customers = get_users(apply_filters('getpaid_ajax_invoice_customers_query_args', $customer_args));
921 921
         $data      = array();
922 922
 
923
-        foreach ( $customers as $customer ) {
923
+        foreach ($customers as $customer) {
924 924
             $data[] = array(
925 925
                 'id'        => (int) $customer->ID,
926
-                'text'      => strip_tags( sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ) ),
926
+                'text'      => strip_tags(sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email)),
927 927
             );
928 928
         }
929 929
 
930
-        wp_send_json_success( $data );
930
+        wp_send_json_success($data);
931 931
 
932 932
     }
933 933
 
@@ -937,28 +937,28 @@  discard block
 block discarded – undo
937 937
     public static function get_aui_states_field() {
938 938
 
939 939
         // Verify nonce.
940
-        check_ajax_referer( 'wpinv-nonce' );
940
+        check_ajax_referer('wpinv-nonce');
941 941
 
942 942
         // We need a country.
943
-        if ( empty( $_GET['country'] ) ) {
943
+        if (empty($_GET['country'])) {
944 944
             exit;
945 945
         }
946 946
 
947
-        $states = wpinv_get_country_states( sanitize_text_field( $_GET['country'] ) );
948
-        $state  = isset( $_GET['state'] ) ? sanitize_text_field( $_GET['state'] ) : wpinv_get_default_state();
949
-        $name   = isset( $_GET['name'] ) ? sanitize_text_field( $_GET['name'] ) : 'wpinv_state';
950
-        $class  = isset( $_GET['class'] ) ? sanitize_text_field( $_GET['class'] ) : 'form-control-sm';
947
+        $states = wpinv_get_country_states(sanitize_text_field($_GET['country']));
948
+        $state  = isset($_GET['state']) ? sanitize_text_field($_GET['state']) : wpinv_get_default_state();
949
+        $name   = isset($_GET['name']) ? sanitize_text_field($_GET['name']) : 'wpinv_state';
950
+        $class  = isset($_GET['class']) ? sanitize_text_field($_GET['class']) : 'form-control-sm';
951 951
 
952
-        if ( empty( $states ) ) {
952
+        if (empty($states)) {
953 953
 
954 954
             $html = aui()->input(
955 955
                 array(
956 956
                     'type'        => 'text',
957 957
                     'id'          => 'wpinv_state',
958 958
                     'name'        => $name,
959
-                    'label'       => __( 'State', 'invoicing' ),
959
+                    'label'       => __('State', 'invoicing'),
960 960
                     'label_type'  => 'vertical',
961
-                    'placeholder' => __( 'State', 'invoicing' ),
961
+                    'placeholder' => __('State', 'invoicing'),
962 962
                     'class'       => $class,
963 963
                     'value'       => $state,
964 964
                 )
@@ -970,9 +970,9 @@  discard block
 block discarded – undo
970 970
                 array(
971 971
                     'id'          => 'wpinv_state',
972 972
                     'name'        => $name,
973
-                    'label'       => __( 'State', 'invoicing' ),
973
+                    'label'       => __('State', 'invoicing'),
974 974
                     'label_type'  => 'vertical',
975
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
975
+                    'placeholder' => __('Select a state', 'invoicing'),
976 976
                     'class'       => $class,
977 977
                     'value'       => $state,
978 978
                     'options'     => $states,
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
         wp_send_json_success(
987 987
             array(
988 988
                 'html'   => $html,
989
-                'select' => ! empty ( $states )
989
+                'select' => !empty ($states)
990 990
             )
991 991
         );
992 992
 
@@ -1000,11 +1000,11 @@  discard block
 block discarded – undo
1000 1000
     public static function payment_form_refresh_prices() {
1001 1001
 
1002 1002
         // Check nonce.
1003
-        check_ajax_referer( 'getpaid_form_nonce' );
1003
+        check_ajax_referer('getpaid_form_nonce');
1004 1004
 
1005 1005
         // ... form fields...
1006
-        if ( empty( $_POST['getpaid_payment_form_submission'] ) ) {
1007
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
1006
+        if (empty($_POST['getpaid_payment_form_submission'])) {
1007
+            _e('Error: Reload the page and try again.', 'invoicing');
1008 1008
             exit;
1009 1009
         }
1010 1010
 
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
         $submission = new GetPaid_Payment_Form_Submission();
1013 1013
 
1014 1014
         // Do we have an error?
1015
-        if ( ! empty( $submission->last_error ) ) {
1015
+        if (!empty($submission->last_error)) {
1016 1016
             wp_send_json_error(
1017 1017
                 array(
1018 1018
                     'code'  => $submission->last_error_code,
@@ -1022,12 +1022,12 @@  discard block
 block discarded – undo
1022 1022
         }
1023 1023
 
1024 1024
         // Prepare the response.
1025
-        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices( $submission );
1025
+        $response = new GetPaid_Payment_Form_Submission_Refresh_Prices($submission);
1026 1026
 
1027 1027
         // Filter the response.
1028
-        $response = apply_filters( 'getpaid_payment_form_ajax_refresh_prices', $response->response, $submission );
1028
+        $response = apply_filters('getpaid_payment_form_ajax_refresh_prices', $response->response, $submission);
1029 1029
 
1030
-        wp_send_json_success( $response );
1030
+        wp_send_json_success($response);
1031 1031
     }
1032 1032
 
1033 1033
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-items.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -12,80 +12,80 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Items {
14 14
 
15
-	/**
16
-	 * Submission items.
17
-	 * @var GetPaid_Form_Item[]
18
-	 */
19
-	public $items = array();
15
+    /**
16
+     * Submission items.
17
+     * @var GetPaid_Form_Item[]
18
+     */
19
+    public $items = array();
20
+
21
+    /**
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27
+
28
+        $data         = $submission->get_data();
29
+        $payment_form = $submission->get_payment_form();
30
+
31
+        // Prepare the selected items.
32
+        $selected_items = array();
33
+        if ( ! empty( $data['getpaid-items'] ) ) {
34
+            $selected_items = wpinv_clean( $data['getpaid-items'] );
35
+        }
36
+
37
+        // For default forms, ensure that an item has been set.
38
+        if ( $payment_form->is_default() && ( ! $submission->has_invoice() || 'payment_form' == $submission->get_invoice()->get_created_via() ) && isset( $data['getpaid-form-items'] ) ) {
39
+            $form_items = wpinv_clean( $data['getpaid-form-items'] );
40
+            $payment_form->set_items( getpaid_convert_items_to_array( $form_items ) );
41
+        }
42
+
43
+        // Process each individual item.
44
+        foreach ( $payment_form->get_items() as $item ) {
45
+            $this->process_item( $item, $selected_items, $submission );
46
+        }
47
+
48
+    }
20 49
 
21 50
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
27
-
28
-		$data         = $submission->get_data();
29
-		$payment_form = $submission->get_payment_form();
30
-
31
-		// Prepare the selected items.
32
-		$selected_items = array();
33
-		if ( ! empty( $data['getpaid-items'] ) ) {
34
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
35
-		}
36
-
37
-		// For default forms, ensure that an item has been set.
38
-		if ( $payment_form->is_default() && ( ! $submission->has_invoice() || 'payment_form' == $submission->get_invoice()->get_created_via() ) && isset( $data['getpaid-form-items'] ) ) {
39
-			$form_items = wpinv_clean( $data['getpaid-form-items'] );
40
-			$payment_form->set_items( getpaid_convert_items_to_array( $form_items ) );
41
-		}
42
-
43
-		// Process each individual item.
44
-		foreach ( $payment_form->get_items() as $item ) {
45
-			$this->process_item( $item, $selected_items, $submission );
46
-		}
47
-
48
-	}
49
-
50
-	/**
51
-	 * Process a single item.
52
-	 *
53
-	 * @param GetPaid_Form_Item $item
54
-	 * @param array $selected_items
55
-	 * @param GetPaid_Payment_Form_Submission $submission
56
-	 */
57
-	public function process_item( $item, $selected_items, $submission ) {
58
-
59
-		// Abort if this is an optional item and it has not been selected.
60
-		if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
61
-			return;
62
-		}
63
-
64
-		// (maybe) let customers change the quantities and prices.
65
-		if ( isset( $selected_items[ $item->get_id() ] ) ) {
66
-
67
-			// Maybe change the quantities.
68
-			if ( $item->allows_quantities() ) {
69
-				$item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] );
70
-			}
71
-
72
-			// Maybe change the price.
73
-			if ( $item->user_can_set_their_price() ) {
74
-				$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
75
-
76
-				if ( $item->get_minimum_price() > $price ) {
77
-					throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), getpaid_unstandardize_amount( $item->get_minimum_price() ) ) );
78
-				}
79
-
80
-				$item->set_price( $price );
81
-
82
-			}
83
-
84
-		}
85
-
86
-		// Save the item.
87
-		$this->items[] = apply_filters( 'getpaid_payment_form_submission_processed_item' , $item, $submission );
88
-
89
-	}
51
+     * Process a single item.
52
+     *
53
+     * @param GetPaid_Form_Item $item
54
+     * @param array $selected_items
55
+     * @param GetPaid_Payment_Form_Submission $submission
56
+     */
57
+    public function process_item( $item, $selected_items, $submission ) {
58
+
59
+        // Abort if this is an optional item and it has not been selected.
60
+        if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
61
+            return;
62
+        }
63
+
64
+        // (maybe) let customers change the quantities and prices.
65
+        if ( isset( $selected_items[ $item->get_id() ] ) ) {
66
+
67
+            // Maybe change the quantities.
68
+            if ( $item->allows_quantities() ) {
69
+                $item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] );
70
+            }
71
+
72
+            // Maybe change the price.
73
+            if ( $item->user_can_set_their_price() ) {
74
+                $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
75
+
76
+                if ( $item->get_minimum_price() > $price ) {
77
+                    throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), getpaid_unstandardize_amount( $item->get_minimum_price() ) ) );
78
+                }
79
+
80
+                $item->set_price( $price );
81
+
82
+            }
83
+
84
+        }
85
+
86
+        // Save the item.
87
+        $this->items[] = apply_filters( 'getpaid_payment_form_submission_processed_item' , $item, $submission );
88
+
89
+    }
90 90
 
91 91
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission itemss class
@@ -23,26 +23,26 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param GetPaid_Payment_Form_Submission $submission
25 25
 	 */
26
-	public function __construct( $submission ) {
26
+	public function __construct($submission) {
27 27
 
28 28
 		$data         = $submission->get_data();
29 29
 		$payment_form = $submission->get_payment_form();
30 30
 
31 31
 		// Prepare the selected items.
32 32
 		$selected_items = array();
33
-		if ( ! empty( $data['getpaid-items'] ) ) {
34
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
33
+		if (!empty($data['getpaid-items'])) {
34
+			$selected_items = wpinv_clean($data['getpaid-items']);
35 35
 		}
36 36
 
37 37
 		// For default forms, ensure that an item has been set.
38
-		if ( $payment_form->is_default() && ( ! $submission->has_invoice() || 'payment_form' == $submission->get_invoice()->get_created_via() ) && isset( $data['getpaid-form-items'] ) ) {
39
-			$form_items = wpinv_clean( $data['getpaid-form-items'] );
40
-			$payment_form->set_items( getpaid_convert_items_to_array( $form_items ) );
38
+		if ($payment_form->is_default() && (!$submission->has_invoice() || 'payment_form' == $submission->get_invoice()->get_created_via()) && isset($data['getpaid-form-items'])) {
39
+			$form_items = wpinv_clean($data['getpaid-form-items']);
40
+			$payment_form->set_items(getpaid_convert_items_to_array($form_items));
41 41
 		}
42 42
 
43 43
 		// Process each individual item.
44
-		foreach ( $payment_form->get_items() as $item ) {
45
-			$this->process_item( $item, $selected_items, $submission );
44
+		foreach ($payment_form->get_items() as $item) {
45
+			$this->process_item($item, $selected_items, $submission);
46 46
 		}
47 47
 
48 48
 	}
@@ -54,37 +54,37 @@  discard block
 block discarded – undo
54 54
 	 * @param array $selected_items
55 55
 	 * @param GetPaid_Payment_Form_Submission $submission
56 56
 	 */
57
-	public function process_item( $item, $selected_items, $submission ) {
57
+	public function process_item($item, $selected_items, $submission) {
58 58
 
59 59
 		// Abort if this is an optional item and it has not been selected.
60
-		if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
60
+		if (!$item->is_required() && !isset($selected_items[$item->get_id()])) {
61 61
 			return;
62 62
 		}
63 63
 
64 64
 		// (maybe) let customers change the quantities and prices.
65
-		if ( isset( $selected_items[ $item->get_id() ] ) ) {
65
+		if (isset($selected_items[$item->get_id()])) {
66 66
 
67 67
 			// Maybe change the quantities.
68
-			if ( $item->allows_quantities() ) {
69
-				$item->set_quantity( (float) $selected_items[ $item->get_id() ]['quantity'] );
68
+			if ($item->allows_quantities()) {
69
+				$item->set_quantity((float) $selected_items[$item->get_id()]['quantity']);
70 70
 			}
71 71
 
72 72
 			// Maybe change the price.
73
-			if ( $item->user_can_set_their_price() ) {
74
-				$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
73
+			if ($item->user_can_set_their_price()) {
74
+				$price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']);
75 75
 
76
-				if ( $item->get_minimum_price() > $price ) {
77
-					throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), getpaid_unstandardize_amount( $item->get_minimum_price() ) ) );
76
+				if ($item->get_minimum_price() > $price) {
77
+					throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), getpaid_unstandardize_amount($item->get_minimum_price())));
78 78
 				}
79 79
 
80
-				$item->set_price( $price );
80
+				$item->set_price($price);
81 81
 
82 82
 			}
83 83
 
84 84
 		}
85 85
 
86 86
 		// Save the item.
87
-		$this->items[] = apply_filters( 'getpaid_payment_form_submission_processed_item' , $item, $submission );
87
+		$this->items[] = apply_filters('getpaid_payment_form_submission_processed_item', $item, $submission);
88 88
 
89 89
 	}
90 90
 
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-fees.php 2 patches
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -12,114 +12,114 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Fees {
14 14
 
15
-	/**
16
-	 * The fee validation error.
17
-	 * @var string
18
-	 */
19
-	public $fee_error;
20
-
21
-	/**
22
-	 * Submission fees.
23
-	 * @var array
24
-	 */
25
-	public $fees = array();
15
+    /**
16
+     * The fee validation error.
17
+     * @var string
18
+     */
19
+    public $fee_error;
20
+
21
+    /**
22
+     * Submission fees.
23
+     * @var array
24
+     */
25
+    public $fees = array();
26
+
27
+    /**
28
+     * Class constructor
29
+     *
30
+     * @param GetPaid_Payment_Form_Submission $submission
31
+     */
32
+    public function __construct( $submission ) {
33
+
34
+        // Process any existing invoice fees.
35
+        if ( $submission->has_invoice() ) {
36
+            $this->fees = $submission->get_invoice()->get_fees();
37
+        }
38
+
39
+        // Process price fields.
40
+        $data         = $submission->get_data();
41
+        $payment_form = $submission->get_payment_form();
42
+
43
+        foreach ( $payment_form->get_elements() as $element ) {
44
+
45
+            if ( 'price_input' == $element['type'] ) {
46
+                $this->process_price_input( $element, $data, $submission );
47
+            }
48
+
49
+            if ( 'price_select' == $element['type'] ) {
50
+                $this->process_price_select( $element, $data );
51
+            }
52
+
53
+        }
54
+
55
+    }
56
+
57
+    /**
58
+     * Process a price input field.
59
+     *
60
+     * @param array $element
61
+     * @param array $data
62
+     * @param GetPaid_Payment_Form_Submission $submission
63
+     */
64
+    public function process_price_input( $element, $data, $submission ) {
65
+
66
+        // Abort if not passed.
67
+        if ( empty( $data[ $element['id'] ] ) ) {
68
+            return;
69
+        }
70
+
71
+        $amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
72
+        $minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] );
73
+
74
+        if ( $amount < $minimum ) {
75
+            throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), getpaid_unstandardize_amount( $minimum, $submission->get_currency() ) ) );
76
+        }
77
+
78
+        $this->fees[ $element['label'] ] = array(
79
+            'name'          => $element['label'],
80
+            'initial_fee'   => $amount,
81
+            'recurring_fee' => 0,
82
+        );
83
+
84
+    }
26 85
 
27 86
     /**
28
-	 * Class constructor
29
-	 *
30
-	 * @param GetPaid_Payment_Form_Submission $submission
31
-	 */
32
-	public function __construct( $submission ) {
33
-
34
-		// Process any existing invoice fees.
35
-		if ( $submission->has_invoice() ) {
36
-			$this->fees = $submission->get_invoice()->get_fees();
37
-		}
38
-
39
-		// Process price fields.
40
-		$data         = $submission->get_data();
41
-		$payment_form = $submission->get_payment_form();
42
-
43
-		foreach ( $payment_form->get_elements() as $element ) {
44
-
45
-			if ( 'price_input' == $element['type'] ) {
46
-				$this->process_price_input( $element, $data, $submission );
47
-			}
48
-
49
-			if ( 'price_select' == $element['type'] ) {
50
-				$this->process_price_select( $element, $data );
51
-			}
52
-
53
-		}
54
-
55
-	}
56
-
57
-	/**
58
-	 * Process a price input field.
59
-	 *
60
-	 * @param array $element
61
-	 * @param array $data
62
-	 * @param GetPaid_Payment_Form_Submission $submission
63
-	 */
64
-	public function process_price_input( $element, $data, $submission ) {
65
-
66
-		// Abort if not passed.
67
-		if ( empty( $data[ $element['id'] ] ) ) {
68
-			return;
69
-		}
70
-
71
-		$amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
72
-		$minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] );
73
-
74
-		if ( $amount < $minimum ) {
75
-			throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), getpaid_unstandardize_amount( $minimum, $submission->get_currency() ) ) );
76
-		}
77
-
78
-		$this->fees[ $element['label'] ] = array(
79
-			'name'          => $element['label'],
80
-			'initial_fee'   => $amount,
81
-			'recurring_fee' => 0,
82
-		);
83
-
84
-	}
85
-
86
-	/**
87
-	 * Process a price select field.
88
-	 *
89
-	 * @param array $element
90
-	 * @param array $data
91
-	 */
92
-	public function process_price_select( $element, $data ) {
93
-
94
-		// Abort if not passed.
95
-		if ( empty( $data[ $element['id'] ] ) ) {
96
-			return;
97
-		}
98
-
99
-		$options    = getpaid_convert_price_string_to_options( $element['options'] );
100
-		$selected   = array_filter( array_map( 'trim', explode( ',', $data[ $element['id'] ] ) ) );
101
-		$total      = 0;
102
-		$sub_labels = array();
103
-
104
-		foreach ( $selected as $price ) {
105
-
106
-			if ( ! isset( $options[ $price ] ) ) {
107
-				throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) );
108
-			}
109
-
110
-			$price = explode( '|', $price );
111
-
112
-			$sub_labels[] = $price[0];
113
-			$total += (float) wpinv_sanitize_amount( $price[1] );
114
-		}
115
-
116
-		$this->fees[ $element['label'] ] = array(
117
-			'name'          => $element['label'],
118
-			'initial_fee'   => $total,
119
-			'recurring_fee' => 0,
120
-			'description'   => implode( ', ', $sub_labels ),
121
-		);
122
-
123
-	}
87
+     * Process a price select field.
88
+     *
89
+     * @param array $element
90
+     * @param array $data
91
+     */
92
+    public function process_price_select( $element, $data ) {
93
+
94
+        // Abort if not passed.
95
+        if ( empty( $data[ $element['id'] ] ) ) {
96
+            return;
97
+        }
98
+
99
+        $options    = getpaid_convert_price_string_to_options( $element['options'] );
100
+        $selected   = array_filter( array_map( 'trim', explode( ',', $data[ $element['id'] ] ) ) );
101
+        $total      = 0;
102
+        $sub_labels = array();
103
+
104
+        foreach ( $selected as $price ) {
105
+
106
+            if ( ! isset( $options[ $price ] ) ) {
107
+                throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) );
108
+            }
109
+
110
+            $price = explode( '|', $price );
111
+
112
+            $sub_labels[] = $price[0];
113
+            $total += (float) wpinv_sanitize_amount( $price[1] );
114
+        }
115
+
116
+        $this->fees[ $element['label'] ] = array(
117
+            'name'          => $element['label'],
118
+            'initial_fee'   => $total,
119
+            'recurring_fee' => 0,
120
+            'description'   => implode( ', ', $sub_labels ),
121
+        );
122
+
123
+    }
124 124
 
125 125
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission fees class
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param GetPaid_Payment_Form_Submission $submission
31 31
 	 */
32
-	public function __construct( $submission ) {
32
+	public function __construct($submission) {
33 33
 
34 34
 		// Process any existing invoice fees.
35
-		if ( $submission->has_invoice() ) {
35
+		if ($submission->has_invoice()) {
36 36
 			$this->fees = $submission->get_invoice()->get_fees();
37 37
 		}
38 38
 
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 		$data         = $submission->get_data();
41 41
 		$payment_form = $submission->get_payment_form();
42 42
 
43
-		foreach ( $payment_form->get_elements() as $element ) {
43
+		foreach ($payment_form->get_elements() as $element) {
44 44
 
45
-			if ( 'price_input' == $element['type'] ) {
46
-				$this->process_price_input( $element, $data, $submission );
45
+			if ('price_input' == $element['type']) {
46
+				$this->process_price_input($element, $data, $submission);
47 47
 			}
48 48
 
49
-			if ( 'price_select' == $element['type'] ) {
50
-				$this->process_price_select( $element, $data );
49
+			if ('price_select' == $element['type']) {
50
+				$this->process_price_select($element, $data);
51 51
 			}
52 52
 
53 53
 		}
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
 	 * @param array $data
62 62
 	 * @param GetPaid_Payment_Form_Submission $submission
63 63
 	 */
64
-	public function process_price_input( $element, $data, $submission ) {
64
+	public function process_price_input($element, $data, $submission) {
65 65
 
66 66
 		// Abort if not passed.
67
-		if ( empty( $data[ $element['id'] ] ) ) {
67
+		if (empty($data[$element['id']])) {
68 68
 			return;
69 69
 		}
70 70
 
71
-		$amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
72
-		$minimum = empty( $element['minimum'] ) ? 0 : (float) wpinv_sanitize_amount( $element['minimum'] );
71
+		$amount  = (float) wpinv_sanitize_amount($data[$element['id']]);
72
+		$minimum = empty($element['minimum']) ? 0 : (float) wpinv_sanitize_amount($element['minimum']);
73 73
 
74
-		if ( $amount < $minimum ) {
75
-			throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), getpaid_unstandardize_amount( $minimum, $submission->get_currency() ) ) );
74
+		if ($amount < $minimum) {
75
+			throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), getpaid_unstandardize_amount($minimum, $submission->get_currency())));
76 76
 		}
77 77
 
78
-		$this->fees[ $element['label'] ] = array(
78
+		$this->fees[$element['label']] = array(
79 79
 			'name'          => $element['label'],
80 80
 			'initial_fee'   => $amount,
81 81
 			'recurring_fee' => 0,
@@ -89,35 +89,35 @@  discard block
 block discarded – undo
89 89
 	 * @param array $element
90 90
 	 * @param array $data
91 91
 	 */
92
-	public function process_price_select( $element, $data ) {
92
+	public function process_price_select($element, $data) {
93 93
 
94 94
 		// Abort if not passed.
95
-		if ( empty( $data[ $element['id'] ] ) ) {
95
+		if (empty($data[$element['id']])) {
96 96
 			return;
97 97
 		}
98 98
 
99
-		$options    = getpaid_convert_price_string_to_options( $element['options'] );
100
-		$selected   = array_filter( array_map( 'trim', explode( ',', $data[ $element['id'] ] ) ) );
99
+		$options    = getpaid_convert_price_string_to_options($element['options']);
100
+		$selected   = array_filter(array_map('trim', explode(',', $data[$element['id']])));
101 101
 		$total      = 0;
102 102
 		$sub_labels = array();
103 103
 
104
-		foreach ( $selected as $price ) {
104
+		foreach ($selected as $price) {
105 105
 
106
-			if ( ! isset( $options[ $price ] ) ) {
107
-				throw new Exception( __( 'You have selected an invalid amount', 'invoicing' ) );
106
+			if (!isset($options[$price])) {
107
+				throw new Exception(__('You have selected an invalid amount', 'invoicing'));
108 108
 			}
109 109
 
110
-			$price = explode( '|', $price );
110
+			$price = explode('|', $price);
111 111
 
112 112
 			$sub_labels[] = $price[0];
113
-			$total += (float) wpinv_sanitize_amount( $price[1] );
113
+			$total += (float) wpinv_sanitize_amount($price[1]);
114 114
 		}
115 115
 
116
-		$this->fees[ $element['label'] ] = array(
116
+		$this->fees[$element['label']] = array(
117 117
 			'name'          => $element['label'],
118 118
 			'initial_fee'   => $total,
119 119
 			'recurring_fee' => 0,
120
-			'description'   => implode( ', ', $sub_labels ),
120
+			'description'   => implode(', ', $sub_labels),
121 121
 		);
122 122
 
123 123
 	}
Please login to merge, or discard this patch.