Completed
Push — master ( 9041b7...12aea4 )
by Brian
18s queued 14s
created
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,25 +13,25 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
17
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
18
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
19
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
20
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
21
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
22
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
17
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
18
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
19
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
20
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
21
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
22
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
23 23
     }
24 24
 
25 25
     public function admin_menu() {
26 26
 
27
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
27
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
28 28
         add_menu_page(
29
-            __( 'GetPaid', 'invoicing' ),
30
-            __( 'GetPaid', 'invoicing' ),
29
+            __('GetPaid', 'invoicing'),
30
+            __('GetPaid', 'invoicing'),
31 31
             $capability,
32 32
             'wpinv',
33 33
             null,
34
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
34
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
35 35
             '54.123460'
36 36
         );
37 37
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     public function add_customers_menu() {
44 44
         add_submenu_page(
45 45
             'wpinv',
46
-            __( 'Customers', 'invoicing' ),
47
-            __( 'Customers', 'invoicing' ),
46
+            __('Customers', 'invoicing'),
47
+            __('Customers', 'invoicing'),
48 48
             wpinv_get_capability(),
49 49
             'wpinv-customers',
50
-            array( $this, 'customers_page' )
50
+            array($this, 'customers_page')
51 51
         );
52 52
     }
53 53
 
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
     public function add_subscriptions_menu() {
58 58
         add_submenu_page(
59 59
             'wpinv',
60
-            __( 'Subscriptions', 'invoicing' ),
61
-            __( 'Subscriptions', 'invoicing' ),
60
+            __('Subscriptions', 'invoicing'),
61
+            __('Subscriptions', 'invoicing'),
62 62
             wpinv_get_capability(),
63 63
             'wpinv-subscriptions',
64 64
             'wpinv_subscriptions_page'
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * Displays the customers page.
70 70
      */
71 71
     public function customers_page() {
72
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' );
72
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php');
73 73
         ?>
74 74
         <div class="wrap wpi-customers-wrap">
75 75
             <style>
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
                     width: 30%;
78 78
                 }
79 79
             </style>
80
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?></h1>
80
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?></h1>
81 81
             <form method="post">
82 82
             <?php
83 83
                 $table = new WPInv_Customers_Table();
84 84
                 $table->prepare_items();
85
-                $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' );
85
+                $table->search_box(__('Search Customers', 'invoicing'), 'search-customers');
86 86
                 $table->display();
87 87
             ?>
88 88
             </form>
@@ -96,16 +96,16 @@  discard block
 block discarded – undo
96 96
     public function add_settings_menu() {
97 97
         add_submenu_page(
98 98
             'wpinv',
99
-            __( 'Invoice Settings', 'invoicing' ),
100
-            __( 'Settings', 'invoicing' ),
101
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
99
+            __('Invoice Settings', 'invoicing'),
100
+            __('Settings', 'invoicing'),
101
+            apply_filters('invoicing_capability', wpinv_get_capability()),
102 102
             'wpinv-settings',
103
-            array( $this, 'options_page' )
103
+            array($this, 'options_page')
104 104
         );
105 105
     }
106 106
 
107
-    public function add_addons_menu(){
108
-        if ( !apply_filters( 'wpi_show_addons_page', true ) ) {
107
+    public function add_addons_menu() {
108
+        if (!apply_filters('wpi_show_addons_page', true)) {
109 109
             return;
110 110
         }
111 111
 
@@ -115,78 +115,78 @@  discard block
 block discarded – undo
115 115
             __('Extensions', 'invoicing'),
116 116
             'manage_options',
117 117
             'wpi-addons',
118
-            array( $this, 'addons_page' )
118
+            array($this, 'addons_page')
119 119
         );
120 120
     }
121 121
 
122
-    public function addons_page(){
122
+    public function addons_page() {
123 123
         $addon_obj = new WPInv_Admin_Addons();
124 124
         $addon_obj->output();
125 125
     }
126 126
 
127 127
     function options_page() {
128
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
128
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
129 129
 
130
-        if ( $page !== 'wpinv-settings' ) {
130
+        if ($page !== 'wpinv-settings') {
131 131
             return;
132 132
         }
133 133
 
134 134
         $settings_tabs = wpinv_get_settings_tabs();
135 135
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
136
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
137
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
136
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
137
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
138 138
         $key           = 'main';
139 139
 
140
-        if ( is_array( $sections ) ) {
141
-            $key = key( $sections );
140
+        if (is_array($sections)) {
141
+            $key = key($sections);
142 142
         }
143 143
 
144
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
145
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
144
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
145
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
146 146
         ob_start();
147 147
         ?>
148 148
         <div class="wrap">
149 149
             <h1 class="nav-tab-wrapper">
150 150
                 <?php
151
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
152
-                    $tab_url = add_query_arg( array(
151
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
152
+                    $tab_url = add_query_arg(array(
153 153
                         'settings-updated' => false,
154 154
                         'tab' => $tab_id,
155
-                    ) );
155
+                    ));
156 156
 
157 157
                     // Remove the section from the tabs so we always end up at the main section
158
-                    $tab_url = remove_query_arg( 'section', $tab_url );
159
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
158
+                    $tab_url = remove_query_arg('section', $tab_url);
159
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
160 160
 
161 161
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
162 162
 
163
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
164
-                    echo esc_html( $tab_name );
163
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
164
+                    echo esc_html($tab_name);
165 165
                     echo '</a>';
166 166
                 }
167 167
                 ?>
168 168
             </h1>
169 169
             <?php
170
-            $number_of_sections = count( $sections );
170
+            $number_of_sections = count($sections);
171 171
             $number = 0;
172
-            if ( $number_of_sections > 1 ) {
172
+            if ($number_of_sections > 1) {
173 173
                 echo '<div><ul class="subsubsub">';
174
-                foreach( $sections as $section_id => $section_name ) {
174
+                foreach ($sections as $section_id => $section_name) {
175 175
                     echo '<li>';
176 176
                     $number++;
177
-                    $tab_url = add_query_arg( array(
177
+                    $tab_url = add_query_arg(array(
178 178
                         'settings-updated' => false,
179 179
                         'tab' => $active_tab,
180 180
                         'section' => $section_id
181
-                    ) );
182
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
181
+                    ));
182
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
183 183
                     $class = '';
184
-                    if ( $section == $section_id ) {
184
+                    if ($section == $section_id) {
185 185
                         $class = 'current';
186 186
                     }
187
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
187
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
188 188
 
189
-                    if ( $number != $number_of_sections ) {
189
+                    if ($number != $number_of_sections) {
190 190
                         echo ' | ';
191 191
                     }
192 192
                     echo '</li>';
@@ -198,20 +198,20 @@  discard block
 block discarded – undo
198 198
                 <form method="post" action="options.php">
199 199
                     <table class="form-table">
200 200
                         <?php
201
-                        settings_fields( 'wpinv_settings' );
201
+                        settings_fields('wpinv_settings');
202 202
 
203
-                        if ( 'main' === $section ) {
204
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
203
+                        if ('main' === $section) {
204
+                            do_action('wpinv_settings_tab_top', $active_tab);
205 205
                         }
206 206
 
207
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
208
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
209
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
210
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
207
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
208
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
209
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
210
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
211 211
 
212 212
                         // For backwards compatibility
213
-                        if ( 'main' === $section ) {
214
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
213
+                        if ('main' === $section) {
214
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
215 215
                         }
216 216
                         ?>
217 217
                     </table>
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
     }
226 226
 
227 227
     public function remove_admin_submenus() {
228
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
228
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
229 229
     }
230 230
 
231 231
     /**
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 
236 236
         add_meta_box(
237 237
             'wpinv_endpoints_nav_link',
238
-            __( 'GetPaid endpoints', 'invoicing' ),
239
-            array( $this, 'nav_menu_links' ),
238
+            __('GetPaid endpoints', 'invoicing'),
239
+            array($this, 'nav_menu_links'),
240 240
             'nav-menus',
241 241
             'side',
242 242
             'low'
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
         $endpoints = $this->get_menu_items();
252 252
         ?>
253 253
         <div id="invoicing-endpoints" class="posttypediv">
254
-            <?php if ( ! empty( $endpoints['pages'] ) ) : ?>
254
+            <?php if (!empty($endpoints['pages'])) : ?>
255 255
                 <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
256 256
                     <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
257 257
                         <?php
258
-                            $walker = new Walker_Nav_Menu_Checklist( array() );
259
-                            echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) );
258
+                            $walker = new Walker_Nav_Menu_Checklist(array());
259
+                            echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
260 260
                         ?>
261 261
                     </ul>
262 262
                 </div>
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
             <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints">
266 266
                 <span class="list-controls hide-if-no-js">
267 267
                     <input type="checkbox" id="invoicing-endpoints-tab" class="select-all">
268
-                    <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label>
268
+                    <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label>
269 269
                 </span>
270 270
 
271 271
                 <span class="add-to-menu">
272
-                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
272
+                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
273 273
                     <span class="spinner"></span>
274 274
                 </span>
275 275
             </p>
@@ -282,35 +282,35 @@  discard block
 block discarded – undo
282 282
      *
283 283
      * @return array.
284 284
      */
285
-    public function get_menu_items(){
285
+    public function get_menu_items() {
286 286
         $items = array();
287 287
 
288 288
         $pages = array(
289 289
             array(
290
-                'id'    => wpinv_get_option( 'invoice_history_page' ),
291
-                'label' => __( 'My Invoices', 'invoicing' ),
290
+                'id'    => wpinv_get_option('invoice_history_page'),
291
+                'label' => __('My Invoices', 'invoicing'),
292 292
             ),
293 293
             array(
294
-                'id'    => wpinv_get_option( 'invoice_subscription_page' ),
295
-                'label' => __( 'My Subscriptions', 'invoicing' ),
294
+                'id'    => wpinv_get_option('invoice_subscription_page'),
295
+                'label' => __('My Subscriptions', 'invoicing'),
296 296
             )
297 297
         );
298 298
 
299
-        foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) {
299
+        foreach (apply_filters('getpaid_menu_pages', $pages) as $page) {
300 300
 
301
-            if ( (int) $page['id'] > 0 ) {
301
+            if ((int) $page['id'] > 0) {
302 302
 
303 303
                 $item                   = new stdClass();
304 304
                 $item->object_id        = (int) $page['id'];
305 305
                 $item->db_id            = 0;
306
-                $item->object           =  'page';
306
+                $item->object           = 'page';
307 307
                 $item->menu_item_parent = 0;
308 308
                 $item->type             = 'post_type';
309
-                $item->title            = sanitize_text_field( $page['label'] );
310
-                $item->url              = get_permalink( (int) $page['id'] );
309
+                $item->title            = sanitize_text_field($page['label']);
310
+                $item->url              = get_permalink((int) $page['id']);
311 311
                 $item->target           = '';
312 312
                 $item->attr_title       = '';
313
-                $item->classes          = array( 'wpinv-menu-item' );
313
+                $item->classes          = array('wpinv-menu-item');
314 314
                 $item->xfn              = '';
315 315
 
316 316
                 $items['pages'][]       = $item;
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 
320 320
         }
321 321
 
322
-        return apply_filters( 'wpinv_menu_items', $items );
322
+        return apply_filters('wpinv_menu_items', $items);
323 323
     }
324 324
 
325 325
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission.php 2 patches
Indentation   +777 added lines, -777 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,187 +10,187 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Payment_Form_Submission {
11 11
 
12 12
     /**
13
-	 * Submission ID
14
-	 *
15
-	 * @var string
16
-	 */
17
-	public $id = null;
18
-
19
-	/**
20
-	 * The raw submission data.
21
-	 *
22
-	 * @var array
23
-	 */
24
-	protected $data = null;
25
-
26
-	/**
27
-	 * Submission totals
28
-	 *
29
-	 * @var array
30
-	 */
31
-	protected $totals = array(
32
-
33
-		'subtotal'      => array(
34
-			'initial'   => 0,
35
-			'recurring' => 0,
36
-		),
37
-
38
-		'discount'      => array(
39
-			'initial'   => 0,
40
-			'recurring' => 0,
41
-		),
42
-
43
-		'fees'          => array(
44
-			'initial'   => 0,
45
-			'recurring' => 0,
46
-		),
47
-
48
-		'taxes'         => array(
49
-			'initial'   => 0,
50
-			'recurring' => 0,
51
-		),
52
-
53
-	);
54
-
55
-	/**
56
-	 * Sets the associated payment form.
57
-	 *
58
-	 * @var GetPaid_Payment_Form
59
-	 */
13
+     * Submission ID
14
+     *
15
+     * @var string
16
+     */
17
+    public $id = null;
18
+
19
+    /**
20
+     * The raw submission data.
21
+     *
22
+     * @var array
23
+     */
24
+    protected $data = null;
25
+
26
+    /**
27
+     * Submission totals
28
+     *
29
+     * @var array
30
+     */
31
+    protected $totals = array(
32
+
33
+        'subtotal'      => array(
34
+            'initial'   => 0,
35
+            'recurring' => 0,
36
+        ),
37
+
38
+        'discount'      => array(
39
+            'initial'   => 0,
40
+            'recurring' => 0,
41
+        ),
42
+
43
+        'fees'          => array(
44
+            'initial'   => 0,
45
+            'recurring' => 0,
46
+        ),
47
+
48
+        'taxes'         => array(
49
+            'initial'   => 0,
50
+            'recurring' => 0,
51
+        ),
52
+
53
+    );
54
+
55
+    /**
56
+     * Sets the associated payment form.
57
+     *
58
+     * @var GetPaid_Payment_Form
59
+     */
60 60
     protected $payment_form = null;
61 61
 
62 62
     /**
63
-	 * The country for the submission.
64
-	 *
65
-	 * @var string
66
-	 */
67
-	public $country = null;
68
-
69
-    /**
70
-	 * The state for the submission.
71
-	 *
72
-	 * @since 1.0.19
73
-	 * @var string
74
-	 */
75
-	public $state = null;
76
-
77
-	/**
78
-	 * The invoice associated with the submission.
79
-	 *
80
-	 * @var WPInv_Invoice
81
-	 */
82
-	protected $invoice = null;
83
-
84
-	/**
85
-	 * The recurring item for the submission.
86
-	 *
87
-	 * @var int
88
-	 */
89
-	public $has_recurring = 0;
90
-
91
-	/**
92
-	 * An array of fees for the submission.
93
-	 *
94
-	 * @var array
95
-	 */
96
-	protected $fees = array();
97
-
98
-	/**
99
-	 * An array of discounts for the submission.
100
-	 *
101
-	 * @var array
102
-	 */
103
-	protected $discounts = array();
104
-
105
-	/**
106
-	 * An array of taxes for the submission.
107
-	 *
108
-	 * @var array
109
-	 */
110
-	protected $taxes = array();
111
-
112
-	/**
113
-	 * An array of items for the submission.
114
-	 *
115
-	 * @var GetPaid_Form_Item[]
116
-	 */
117
-	protected $items = array();
118
-
119
-	/**
120
-	 * The last error.
121
-	 *
122
-	 * @var string
123
-	 */
124
-	public $last_error = null;
125
-
126
-    /**
127
-	 * Class constructor.
128
-	 *
129
-	 */
130
-	public function __construct() {
131
-
132
-		// Set the state and country to the default state and country.
133
-		$this->country = wpinv_default_billing_country();
134
-		$this->state   = wpinv_get_default_state();
135
-
136
-		// Do we have an actual submission?
137
-		if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
138
-			$this->load_data( $_POST );
139
-		}
140
-
141
-	}
142
-
143
-	/**
144
-	 * Loads submission data.
145
-	 *
146
-	 * @param array $data
147
-	 */
148
-	public function load_data( $data ) {
149
-
150
-		// Remove slashes from the submitted data...
151
-		$data       = wp_unslash( $data );
152
-
153
-		// Allow plugins to filter the data.
154
-		$data       = apply_filters( 'getpaid_submission_data', $data, $this );
155
-
156
-		// Cache it...
157
-		$this->data = $data;
158
-
159
-		// Then generate a unique id from the data.
160
-		$this->id   = md5( wp_json_encode( $data ) );
161
-
162
-		// Finally, process the submission.
163
-		try {
164
-
165
-			// Each process is passed an instance of the class (with reference)
166
-			// and should throw an Exception whenever it encounters one.
167
-			$processors = apply_filters(
168
-				'getpaid_payment_form_submission_processors',
169
-				array(
170
-					array( $this, 'process_payment_form' ),
171
-					array( $this, 'process_invoice' ),
172
-					array( $this, 'process_fees' ),
173
-					array( $this, 'process_items' ),
174
-					array( $this, 'process_discount' ),
175
-					array( $this, 'process_taxes' ),
176
-				),
177
-				$this		
178
-			);
179
-
180
-			foreach ( $processors as $processor ) {
181
-				call_user_func_array( $processor, array( &$this ) );
182
-			}
183
-
184
-		} catch ( Exception $e ) {
185
-			$this->last_error = $e->getMessage();
186
-		}
187
-
188
-		// Fired when we are done processing a submission.
189
-		do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
190
-
191
-	}
192
-
193
-	/*
63
+     * The country for the submission.
64
+     *
65
+     * @var string
66
+     */
67
+    public $country = null;
68
+
69
+    /**
70
+     * The state for the submission.
71
+     *
72
+     * @since 1.0.19
73
+     * @var string
74
+     */
75
+    public $state = null;
76
+
77
+    /**
78
+     * The invoice associated with the submission.
79
+     *
80
+     * @var WPInv_Invoice
81
+     */
82
+    protected $invoice = null;
83
+
84
+    /**
85
+     * The recurring item for the submission.
86
+     *
87
+     * @var int
88
+     */
89
+    public $has_recurring = 0;
90
+
91
+    /**
92
+     * An array of fees for the submission.
93
+     *
94
+     * @var array
95
+     */
96
+    protected $fees = array();
97
+
98
+    /**
99
+     * An array of discounts for the submission.
100
+     *
101
+     * @var array
102
+     */
103
+    protected $discounts = array();
104
+
105
+    /**
106
+     * An array of taxes for the submission.
107
+     *
108
+     * @var array
109
+     */
110
+    protected $taxes = array();
111
+
112
+    /**
113
+     * An array of items for the submission.
114
+     *
115
+     * @var GetPaid_Form_Item[]
116
+     */
117
+    protected $items = array();
118
+
119
+    /**
120
+     * The last error.
121
+     *
122
+     * @var string
123
+     */
124
+    public $last_error = null;
125
+
126
+    /**
127
+     * Class constructor.
128
+     *
129
+     */
130
+    public function __construct() {
131
+
132
+        // Set the state and country to the default state and country.
133
+        $this->country = wpinv_default_billing_country();
134
+        $this->state   = wpinv_get_default_state();
135
+
136
+        // Do we have an actual submission?
137
+        if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
138
+            $this->load_data( $_POST );
139
+        }
140
+
141
+    }
142
+
143
+    /**
144
+     * Loads submission data.
145
+     *
146
+     * @param array $data
147
+     */
148
+    public function load_data( $data ) {
149
+
150
+        // Remove slashes from the submitted data...
151
+        $data       = wp_unslash( $data );
152
+
153
+        // Allow plugins to filter the data.
154
+        $data       = apply_filters( 'getpaid_submission_data', $data, $this );
155
+
156
+        // Cache it...
157
+        $this->data = $data;
158
+
159
+        // Then generate a unique id from the data.
160
+        $this->id   = md5( wp_json_encode( $data ) );
161
+
162
+        // Finally, process the submission.
163
+        try {
164
+
165
+            // Each process is passed an instance of the class (with reference)
166
+            // and should throw an Exception whenever it encounters one.
167
+            $processors = apply_filters(
168
+                'getpaid_payment_form_submission_processors',
169
+                array(
170
+                    array( $this, 'process_payment_form' ),
171
+                    array( $this, 'process_invoice' ),
172
+                    array( $this, 'process_fees' ),
173
+                    array( $this, 'process_items' ),
174
+                    array( $this, 'process_discount' ),
175
+                    array( $this, 'process_taxes' ),
176
+                ),
177
+                $this		
178
+            );
179
+
180
+            foreach ( $processors as $processor ) {
181
+                call_user_func_array( $processor, array( &$this ) );
182
+            }
183
+
184
+        } catch ( Exception $e ) {
185
+            $this->last_error = $e->getMessage();
186
+        }
187
+
188
+        // Fired when we are done processing a submission.
189
+        do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
190
+
191
+    }
192
+
193
+    /*
194 194
 	|--------------------------------------------------------------------------
195 195
 	| Payment Forms.
196 196
 	|--------------------------------------------------------------------------
@@ -199,39 +199,39 @@  discard block
 block discarded – undo
199 199
 	| submission has an active payment form etc.
200 200
     */
201 201
 
202
-	/**
203
-	 * Prepares the submission's payment form.
204
-	 *
205
-	 * @since 1.0.19
206
-	 */
207
-	public function process_payment_form() {
202
+    /**
203
+     * Prepares the submission's payment form.
204
+     *
205
+     * @since 1.0.19
206
+     */
207
+    public function process_payment_form() {
208 208
 
209
-		// Every submission needs an active payment form.
210
-		if ( empty( $this->data['form_id'] ) ) {
211
-			throw new Exception( __( 'Missing payment form', 'invoicing' ) );
212
-		}
209
+        // Every submission needs an active payment form.
210
+        if ( empty( $this->data['form_id'] ) ) {
211
+            throw new Exception( __( 'Missing payment form', 'invoicing' ) );
212
+        }
213 213
 
214
-		// Fetch the payment form.
215
-		$this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] );
214
+        // Fetch the payment form.
215
+        $this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] );
216 216
 
217
-		if ( ! $this->payment_form->is_active() ) {
218
-			throw new Exception( __( 'Payment form not active', 'invoicing' ) );
219
-		}
217
+        if ( ! $this->payment_form->is_active() ) {
218
+            throw new Exception( __( 'Payment form not active', 'invoicing' ) );
219
+        }
220 220
 
221
-		do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) );
222
-	}
221
+        do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) );
222
+    }
223 223
 
224 224
     /**
225
-	 * Returns the payment form.
226
-	 *
227
-	 * @since 1.0.19
228
-	 * @return GetPaid_Payment_Form
229
-	 */
230
-	public function get_payment_form() {
231
-		return $this->payment_form;
232
-	}
225
+     * Returns the payment form.
226
+     *
227
+     * @since 1.0.19
228
+     * @return GetPaid_Payment_Form
229
+     */
230
+    public function get_payment_form() {
231
+        return $this->payment_form;
232
+    }
233 233
 
234
-	/*
234
+    /*
235 235
 	|--------------------------------------------------------------------------
236 236
 	| Invoices.
237 237
 	|--------------------------------------------------------------------------
@@ -240,61 +240,61 @@  discard block
 block discarded – undo
240 240
 	| might be for an existing invoice.
241 241
 	*/
242 242
 
243
-	/**
244
-	 * Prepares the submission's invoice.
245
-	 *
246
-	 * @since 1.0.19
247
-	 */
248
-	public function process_invoice() {
243
+    /**
244
+     * Prepares the submission's invoice.
245
+     *
246
+     * @since 1.0.19
247
+     */
248
+    public function process_invoice() {
249 249
 
250
-		// Abort if there is no invoice.
251
-		if ( empty( $this->data['invoice_id'] ) ) {
252
-			return;
253
-		}
250
+        // Abort if there is no invoice.
251
+        if ( empty( $this->data['invoice_id'] ) ) {
252
+            return;
253
+        }
254 254
 
255
-		// If the submission is for an existing invoice, ensure that it exists
256
-		// and that it is not paid for.
257
-		$invoice = wpinv_get_invoice( $this->data['invoice_id'] );
255
+        // If the submission is for an existing invoice, ensure that it exists
256
+        // and that it is not paid for.
257
+        $invoice = wpinv_get_invoice( $this->data['invoice_id'] );
258 258
 
259 259
         if ( empty( $invoice ) ) {
260
-			throw new Exception( __( 'Invalid invoice', 'invoicing' ) );
261
-		}
262
-
263
-		if ( $invoice->is_paid() ) {
264
-			throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) );
265
-		}
266
-
267
-		$this->payment_form->set_items( $invoice->get_items() );
268
-		$this->payment_form->invoice = $invoice;
269
-
270
-		$this->country = $invoice->get_country();
271
-		$this->state   = $invoice->get_state();
272
-		$this->invoice = $invoice;
273
-
274
-		do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) );
275
-	}
276
-
277
-	/**
278
-	 * Returns the associated invoice.
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @return WPInv_Invoice
282
-	 */
283
-	public function get_invoice() {
284
-		return $this->invoice;
285
-	}
286
-
287
-	/**
288
-	 * Checks whether there is an invoice associated with this submission.
289
-	 *
290
-	 * @since 1.0.19
291
-	 * @return bool
292
-	 */
293
-	public function has_invoice() {
294
-		return ! empty( $this->invoice );
295
-	}
296
-
297
-	/*
260
+            throw new Exception( __( 'Invalid invoice', 'invoicing' ) );
261
+        }
262
+
263
+        if ( $invoice->is_paid() ) {
264
+            throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) );
265
+        }
266
+
267
+        $this->payment_form->set_items( $invoice->get_items() );
268
+        $this->payment_form->invoice = $invoice;
269
+
270
+        $this->country = $invoice->get_country();
271
+        $this->state   = $invoice->get_state();
272
+        $this->invoice = $invoice;
273
+
274
+        do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) );
275
+    }
276
+
277
+    /**
278
+     * Returns the associated invoice.
279
+     *
280
+     * @since 1.0.19
281
+     * @return WPInv_Invoice
282
+     */
283
+    public function get_invoice() {
284
+        return $this->invoice;
285
+    }
286
+
287
+    /**
288
+     * Checks whether there is an invoice associated with this submission.
289
+     *
290
+     * @since 1.0.19
291
+     * @return bool
292
+     */
293
+    public function has_invoice() {
294
+        return ! empty( $this->invoice );
295
+    }
296
+
297
+    /*
298 298
 	|--------------------------------------------------------------------------
299 299
 	| Items.
300 300
 	|--------------------------------------------------------------------------
@@ -303,115 +303,115 @@  discard block
 block discarded – undo
303 303
 	| recurring item. But can have an unlimited number of non-recurring items.
304 304
 	*/
305 305
 
306
-	/**
307
-	 * Prepares the submission's items.
308
-	 *
309
-	 * @since 1.0.19
310
-	 */
311
-	public function process_items() {
312
-
313
-		$processor = new GetPaid_Payment_Form_Submission_Items( $this );
314
-
315
-		foreach ( $processor->items as $item ) {
316
-			$this->add_item( $item );
317
-		}
318
-
319
-		do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) );
320
-	}
321
-
322
-	/**
323
-	 * Adds an item to the submission.
324
-	 *
325
-	 * @since 1.0.19
326
-	 * @param GetPaid_Form_Item $item
327
-	 */
328
-	public function add_item( $item ) {
329
-
330
-		// Make sure that it is available for purchase.
331
-		if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) {
332
-			return;
333
-		}
334
-
335
-		// Each submission can only contain one recurring item.
336
-		if ( $item->is_recurring() ) {
337
-
338
-			if ( $this->has_recurring != 0 ) {
339
-				throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) );
340
-			}
341
-
342
-			$this->has_recurring = $item->get_id();
343
-
344
-		}
345
-
346
-		// Update the items and totals.
347
-		$this->items[ $item->get_id() ]         = $item;
348
-		$this->totals['subtotal']['initial']   += $item->get_sub_total();
349
-		$this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total();
350
-
351
-	}
352
-
353
-	/**
354
-	 * Removes a specific item.
355
-	 * 
356
-	 * You should not call this method after the discounts and taxes
357
-	 * have been calculated.
358
-	 *
359
-	 * @since 1.0.19
360
-	 */
361
-	public function remove_item( $item_id ) {
362
-
363
-		if ( isset( $this->items[ $item_id ] ) ) {
364
-			$this->totals['subtotal']['initial']   -= $this->items[ $item_id ]->get_sub_total();
365
-			$this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total();
366
-
367
-			if ( $this->items[ $item_id ]->is_recurring() ) {
368
-				$this->has_recurring = 0;
369
-			}
370
-
371
-			unset( $this->items[ $item_id ] );
372
-		}
373
-
374
-	}
375
-
376
-	/**
377
-	 * Returns the subtotal.
378
-	 *
379
-	 * @since 1.0.19
380
-	 */
381
-	public function get_subtotal() {
382
-
383
-		if ( wpinv_prices_include_tax() ) {
384
-			return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial'];
385
-		}
386
-
387
-		return $this->totals['subtotal']['initial'];
388
-	}
389
-
390
-	/**
391
-	 * Returns the recurring subtotal.
392
-	 *
393
-	 * @since 1.0.19
394
-	 */
395
-	public function get_recurring_subtotal() {
396
-
397
-		if ( wpinv_prices_include_tax() ) {
398
-			return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring'];
399
-		}
400
-
401
-		return $this->totals['subtotal']['recurring'];
402
-	}
403
-
404
-	/**
405
-	 * Returns all items.
406
-	 *
407
-	 * @since 1.0.19
408
-	 * @return GetPaid_Form_Item[]
409
-	 */
410
-	public function get_items() {
411
-		return $this->items;
412
-	}
413
-
414
-	/*
306
+    /**
307
+     * Prepares the submission's items.
308
+     *
309
+     * @since 1.0.19
310
+     */
311
+    public function process_items() {
312
+
313
+        $processor = new GetPaid_Payment_Form_Submission_Items( $this );
314
+
315
+        foreach ( $processor->items as $item ) {
316
+            $this->add_item( $item );
317
+        }
318
+
319
+        do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) );
320
+    }
321
+
322
+    /**
323
+     * Adds an item to the submission.
324
+     *
325
+     * @since 1.0.19
326
+     * @param GetPaid_Form_Item $item
327
+     */
328
+    public function add_item( $item ) {
329
+
330
+        // Make sure that it is available for purchase.
331
+        if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) {
332
+            return;
333
+        }
334
+
335
+        // Each submission can only contain one recurring item.
336
+        if ( $item->is_recurring() ) {
337
+
338
+            if ( $this->has_recurring != 0 ) {
339
+                throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) );
340
+            }
341
+
342
+            $this->has_recurring = $item->get_id();
343
+
344
+        }
345
+
346
+        // Update the items and totals.
347
+        $this->items[ $item->get_id() ]         = $item;
348
+        $this->totals['subtotal']['initial']   += $item->get_sub_total();
349
+        $this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total();
350
+
351
+    }
352
+
353
+    /**
354
+     * Removes a specific item.
355
+     * 
356
+     * You should not call this method after the discounts and taxes
357
+     * have been calculated.
358
+     *
359
+     * @since 1.0.19
360
+     */
361
+    public function remove_item( $item_id ) {
362
+
363
+        if ( isset( $this->items[ $item_id ] ) ) {
364
+            $this->totals['subtotal']['initial']   -= $this->items[ $item_id ]->get_sub_total();
365
+            $this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total();
366
+
367
+            if ( $this->items[ $item_id ]->is_recurring() ) {
368
+                $this->has_recurring = 0;
369
+            }
370
+
371
+            unset( $this->items[ $item_id ] );
372
+        }
373
+
374
+    }
375
+
376
+    /**
377
+     * Returns the subtotal.
378
+     *
379
+     * @since 1.0.19
380
+     */
381
+    public function get_subtotal() {
382
+
383
+        if ( wpinv_prices_include_tax() ) {
384
+            return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial'];
385
+        }
386
+
387
+        return $this->totals['subtotal']['initial'];
388
+    }
389
+
390
+    /**
391
+     * Returns the recurring subtotal.
392
+     *
393
+     * @since 1.0.19
394
+     */
395
+    public function get_recurring_subtotal() {
396
+
397
+        if ( wpinv_prices_include_tax() ) {
398
+            return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring'];
399
+        }
400
+
401
+        return $this->totals['subtotal']['recurring'];
402
+    }
403
+
404
+    /**
405
+     * Returns all items.
406
+     *
407
+     * @since 1.0.19
408
+     * @return GetPaid_Form_Item[]
409
+     */
410
+    public function get_items() {
411
+        return $this->items;
412
+    }
413
+
414
+    /*
415 415
 	|--------------------------------------------------------------------------
416 416
 	| Taxes
417 417
 	|--------------------------------------------------------------------------
@@ -420,128 +420,128 @@  discard block
 block discarded – undo
420 420
 	| or only one-time.
421 421
     */
422 422
 
423
-	/**
424
-	 * Prepares the submission's taxes.
425
-	 *
426
-	 * @since 1.0.19
427
-	 */
428
-	public function process_taxes() {
429
-
430
-		// Abort if we're not using taxes.
431
-		if ( ! $this->use_taxes() ) {
432
-			return;
433
-		}
434
-
435
-		// If a custom country && state has been passed in, use it to calculate taxes.
436
-		$country = $this->get_field( 'wpinv_country', 'billing' );
437
-		if ( ! empty( $country ) ) {
438
-			$this->country = $country;
439
-		}
440
-
441
-		$state = $this->get_field( 'wpinv_state', 'billing' );
442
-		if ( ! empty( $state ) ) {
443
-			$this->state = $state;
444
-		}
445
-
446
-		// Confirm if the provided country and the ip country are similar.
447
-		$address_confirmed = $this->get_field( 'confirm-address' );
448
-		if ( wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty( $address_confirmed ) ) {
449
-			throw new Exception( __( 'The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing' ) );
450
-		}
451
-
452
-		// Abort if the country is not taxable.
453
-		if ( ! wpinv_is_country_taxable( $this->country ) ) {
454
-			return;
455
-		}
456
-
457
-		$processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
458
-
459
-		foreach ( $processor->taxes as $tax ) {
460
-			$this->add_tax( $tax );
461
-		}
462
-
463
-		do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
464
-	}
465
-
466
-	/**
467
-	 * Adds a tax to the submission.
468
-	 *
469
-	 * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
470
-	 * @since 1.0.19
471
-	 */
472
-	public function add_tax( $tax ) {
473
-
474
-		if ( wpinv_round_tax_per_tax_rate() ) {
475
-			$tax['initial_tax']   = wpinv_round_amount( $tax['initial_tax'] );
476
-			$tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] );
477
-		}
478
-
479
-		$this->taxes[ $tax['name'] ]         = $tax;
480
-		$this->totals['taxes']['initial']   += wpinv_sanitize_amount( $tax['initial_tax'] );
481
-		$this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] );
482
-
483
-	}
484
-
485
-	/**
486
-	 * Removes a specific tax.
487
-	 *
488
-	 * @since 1.0.19
489
-	 */
490
-	public function remove_tax( $tax_name ) {
491
-
492
-		if ( isset( $this->taxes[ $tax_name ] ) ) {
493
-			$this->totals['taxes']['initial']   -= $this->taxes[ $tax_name ]['initial_tax'];
494
-			$this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax'];
495
-			unset( $this->taxes[ $tax_name ] );
496
-		}
497
-
498
-	}
499
-
500
-	/**
501
-	 * Whether or not we'll use taxes for the submission.
502
-	 *
503
-	 * @since 1.0.19
504
-	 */
505
-	public function use_taxes() {
506
-
507
-		$use_taxes = wpinv_use_taxes();
508
-
509
-		if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
510
-			$use_taxes = false;
511
-		}
512
-
513
-		return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
514
-
515
-	}
516
-
517
-	/**
518
-	 * Returns the tax.
519
-	 *
520
-	 * @since 1.0.19
521
-	 */
522
-	public function get_tax() {
523
-		return $this->totals['taxes']['initial'];
524
-	}
525
-
526
-	/**
527
-	 * Returns the recurring tax.
528
-	 *
529
-	 * @since 1.0.19
530
-	 */
531
-	public function get_recurring_tax() {
532
-		return $this->totals['taxes']['recurring'];
533
-	}
534
-
535
-	/**
536
-	 * Returns all taxes.
537
-	 *
538
-	 * @since 1.0.19
539
-	 */
540
-	public function get_taxes() {
541
-		return $this->taxes;
542
-	}
543
-
544
-	/*
423
+    /**
424
+     * Prepares the submission's taxes.
425
+     *
426
+     * @since 1.0.19
427
+     */
428
+    public function process_taxes() {
429
+
430
+        // Abort if we're not using taxes.
431
+        if ( ! $this->use_taxes() ) {
432
+            return;
433
+        }
434
+
435
+        // If a custom country && state has been passed in, use it to calculate taxes.
436
+        $country = $this->get_field( 'wpinv_country', 'billing' );
437
+        if ( ! empty( $country ) ) {
438
+            $this->country = $country;
439
+        }
440
+
441
+        $state = $this->get_field( 'wpinv_state', 'billing' );
442
+        if ( ! empty( $state ) ) {
443
+            $this->state = $state;
444
+        }
445
+
446
+        // Confirm if the provided country and the ip country are similar.
447
+        $address_confirmed = $this->get_field( 'confirm-address' );
448
+        if ( wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty( $address_confirmed ) ) {
449
+            throw new Exception( __( 'The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing' ) );
450
+        }
451
+
452
+        // Abort if the country is not taxable.
453
+        if ( ! wpinv_is_country_taxable( $this->country ) ) {
454
+            return;
455
+        }
456
+
457
+        $processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
458
+
459
+        foreach ( $processor->taxes as $tax ) {
460
+            $this->add_tax( $tax );
461
+        }
462
+
463
+        do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
464
+    }
465
+
466
+    /**
467
+     * Adds a tax to the submission.
468
+     *
469
+     * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
470
+     * @since 1.0.19
471
+     */
472
+    public function add_tax( $tax ) {
473
+
474
+        if ( wpinv_round_tax_per_tax_rate() ) {
475
+            $tax['initial_tax']   = wpinv_round_amount( $tax['initial_tax'] );
476
+            $tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] );
477
+        }
478
+
479
+        $this->taxes[ $tax['name'] ]         = $tax;
480
+        $this->totals['taxes']['initial']   += wpinv_sanitize_amount( $tax['initial_tax'] );
481
+        $this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] );
482
+
483
+    }
484
+
485
+    /**
486
+     * Removes a specific tax.
487
+     *
488
+     * @since 1.0.19
489
+     */
490
+    public function remove_tax( $tax_name ) {
491
+
492
+        if ( isset( $this->taxes[ $tax_name ] ) ) {
493
+            $this->totals['taxes']['initial']   -= $this->taxes[ $tax_name ]['initial_tax'];
494
+            $this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax'];
495
+            unset( $this->taxes[ $tax_name ] );
496
+        }
497
+
498
+    }
499
+
500
+    /**
501
+     * Whether or not we'll use taxes for the submission.
502
+     *
503
+     * @since 1.0.19
504
+     */
505
+    public function use_taxes() {
506
+
507
+        $use_taxes = wpinv_use_taxes();
508
+
509
+        if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
510
+            $use_taxes = false;
511
+        }
512
+
513
+        return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
514
+
515
+    }
516
+
517
+    /**
518
+     * Returns the tax.
519
+     *
520
+     * @since 1.0.19
521
+     */
522
+    public function get_tax() {
523
+        return $this->totals['taxes']['initial'];
524
+    }
525
+
526
+    /**
527
+     * Returns the recurring tax.
528
+     *
529
+     * @since 1.0.19
530
+     */
531
+    public function get_recurring_tax() {
532
+        return $this->totals['taxes']['recurring'];
533
+    }
534
+
535
+    /**
536
+     * Returns all taxes.
537
+     *
538
+     * @since 1.0.19
539
+     */
540
+    public function get_taxes() {
541
+        return $this->taxes;
542
+    }
543
+
544
+    /*
545 545
 	|--------------------------------------------------------------------------
546 546
 	| Discounts
547 547
 	|--------------------------------------------------------------------------
@@ -550,99 +550,99 @@  discard block
 block discarded – undo
550 550
 	| or only one-time. They also do not have to come from a discount code.
551 551
     */
552 552
 
553
-	/**
554
-	 * Prepares the submission's discount.
555
-	 *
556
-	 * @since 1.0.19
557
-	 */
558
-	public function process_discount() {
559
-
560
-		$initial_total    = $this->get_subtotal() + $this->get_fee() + $this->get_tax();
561
-		$recurring_total  = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax();
562
-		$processor        = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total );
563
-
564
-		foreach ( $processor->discounts as $discount ) {
565
-			$this->add_discount( $discount );
566
-		}
567
-
568
-		do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
569
-	}
570
-
571
-	/**
572
-	 * Adds a discount to the submission.
573
-	 *
574
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
575
-	 * @since 1.0.19
576
-	 */
577
-	public function add_discount( $discount ) {
578
-		$this->discounts[ $discount['name'] ]   = $discount;
579
-		$this->totals['discount']['initial']   += wpinv_sanitize_amount( $discount['initial_discount'] );
580
-		$this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] );
581
-	}
582
-
583
-	/**
584
-	 * Removes a discount from the submission.
585
-	 *
586
-	 * @since 1.0.19
587
-	 */
588
-	public function remove_discount( $name ) {
589
-
590
-		if ( isset( $this->discounts[ $name ] ) ) {
591
-			$this->totals['discount']['initial']   -= $this->discounts[ $name ]['initial_discount'];
592
-			$this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount'];
593
-			unset( $this->discounts[ $name ] );
594
-		}
595
-
596
-	}
597
-
598
-	/**
599
-	 * Checks whether there is a discount code associated with this submission.
600
-	 *
601
-	 * @since 1.0.19
602
-	 * @return bool
603
-	 */
604
-	public function has_discount_code() {
605
-		return ! empty( $this->discounts['discount_code'] );
606
-	}
607
-
608
-	/**
609
-	 * Returns the discount code.
610
-	 *
611
-	 * @since 1.0.19
612
-	 * @return string
613
-	 */
614
-	public function get_discount_code() {
615
-		return $this->has_discount_code() ? $this->discounts['discount_code']['discount_code'] : '';
616
-	}
617
-
618
-	/**
619
-	 * Returns the discount.
620
-	 *
621
-	 * @since 1.0.19
622
-	 */
623
-	public function get_discount() {
624
-		return $this->totals['discount']['initial'];
625
-	}
626
-
627
-	/**
628
-	 * Returns the recurring discount.
629
-	 *
630
-	 * @since 1.0.19
631
-	 */
632
-	public function get_recurring_discount() {
633
-		return $this->totals['discount']['recurring'];
634
-	}
635
-
636
-	/**
637
-	 * Returns all discounts.
638
-	 *
639
-	 * @since 1.0.19
640
-	 */
641
-	public function get_discounts() {
642
-		return $this->discounts;
643
-	}
644
-
645
-	/*
553
+    /**
554
+     * Prepares the submission's discount.
555
+     *
556
+     * @since 1.0.19
557
+     */
558
+    public function process_discount() {
559
+
560
+        $initial_total    = $this->get_subtotal() + $this->get_fee() + $this->get_tax();
561
+        $recurring_total  = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax();
562
+        $processor        = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total );
563
+
564
+        foreach ( $processor->discounts as $discount ) {
565
+            $this->add_discount( $discount );
566
+        }
567
+
568
+        do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
569
+    }
570
+
571
+    /**
572
+     * Adds a discount to the submission.
573
+     *
574
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
575
+     * @since 1.0.19
576
+     */
577
+    public function add_discount( $discount ) {
578
+        $this->discounts[ $discount['name'] ]   = $discount;
579
+        $this->totals['discount']['initial']   += wpinv_sanitize_amount( $discount['initial_discount'] );
580
+        $this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] );
581
+    }
582
+
583
+    /**
584
+     * Removes a discount from the submission.
585
+     *
586
+     * @since 1.0.19
587
+     */
588
+    public function remove_discount( $name ) {
589
+
590
+        if ( isset( $this->discounts[ $name ] ) ) {
591
+            $this->totals['discount']['initial']   -= $this->discounts[ $name ]['initial_discount'];
592
+            $this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount'];
593
+            unset( $this->discounts[ $name ] );
594
+        }
595
+
596
+    }
597
+
598
+    /**
599
+     * Checks whether there is a discount code associated with this submission.
600
+     *
601
+     * @since 1.0.19
602
+     * @return bool
603
+     */
604
+    public function has_discount_code() {
605
+        return ! empty( $this->discounts['discount_code'] );
606
+    }
607
+
608
+    /**
609
+     * Returns the discount code.
610
+     *
611
+     * @since 1.0.19
612
+     * @return string
613
+     */
614
+    public function get_discount_code() {
615
+        return $this->has_discount_code() ? $this->discounts['discount_code']['discount_code'] : '';
616
+    }
617
+
618
+    /**
619
+     * Returns the discount.
620
+     *
621
+     * @since 1.0.19
622
+     */
623
+    public function get_discount() {
624
+        return $this->totals['discount']['initial'];
625
+    }
626
+
627
+    /**
628
+     * Returns the recurring discount.
629
+     *
630
+     * @since 1.0.19
631
+     */
632
+    public function get_recurring_discount() {
633
+        return $this->totals['discount']['recurring'];
634
+    }
635
+
636
+    /**
637
+     * Returns all discounts.
638
+     *
639
+     * @since 1.0.19
640
+     */
641
+    public function get_discounts() {
642
+        return $this->discounts;
643
+    }
644
+
645
+    /*
646 646
 	|--------------------------------------------------------------------------
647 647
 	| Fees
648 648
 	|--------------------------------------------------------------------------
@@ -652,89 +652,89 @@  discard block
 block discarded – undo
652 652
 	| fees.
653 653
     */
654 654
 
655
-	/**
656
-	 * Prepares the submission's fees.
657
-	 *
658
-	 * @since 1.0.19
659
-	 */
660
-	public function process_fees() {
661
-
662
-		$fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
663
-
664
-		foreach ( $fees_processor->fees as $fee ) {
665
-			$this->add_fee( $fee );
666
-		}
667
-
668
-		do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
669
-	}
670
-
671
-	/**
672
-	 * Adds a fee to the submission.
673
-	 *
674
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
675
-	 * @since 1.0.19
676
-	 */
677
-	public function add_fee( $fee ) {
678
-
679
-		$this->fees[ $fee['name'] ]         = $fee;
680
-		$this->totals['fees']['initial']   += wpinv_sanitize_amount( $fee['initial_fee'] );
681
-		$this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] );
682
-
683
-	}
684
-
685
-	/**
686
-	 * Removes a fee from the submission.
687
-	 *
688
-	 * @since 1.0.19
689
-	 */
690
-	public function remove_fee( $name ) {
691
-
692
-		if ( isset( $this->fees[ $name ] ) ) {
693
-			$this->totals['fees']['initial']   -= $this->fees[ $name ]['initial_fee'];
694
-			$this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee'];
695
-			unset( $this->fees[ $name ] );
696
-		}
697
-
698
-	}
699
-
700
-	/**
701
-	 * Returns the fees.
702
-	 *
703
-	 * @since 1.0.19
704
-	 */
705
-	public function get_fee() {
706
-		return $this->totals['fees']['initial'];
707
-	}
708
-
709
-	/**
710
-	 * Returns the recurring fees.
711
-	 *
712
-	 * @since 1.0.19
713
-	 */
714
-	public function get_recurring_fee() {
715
-		return $this->totals['fees']['recurring'];
716
-	}
717
-
718
-	/**
719
-	 * Returns all fees.
720
-	 *
721
-	 * @since 1.0.19
722
-	 */
723
-	public function get_fees() {
724
-		return $this->fees;
725
-	}
726
-
727
-	/**
728
-	 * Checks if there are any fees for the form.
729
-	 *
730
-	 * @return bool
731
-	 * @since 1.0.19
732
-	 */
733
-	public function has_fees() {
734
-		return count( $this->fees ) !== 0;
735
-	}
736
-
737
-	/*
655
+    /**
656
+     * Prepares the submission's fees.
657
+     *
658
+     * @since 1.0.19
659
+     */
660
+    public function process_fees() {
661
+
662
+        $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
663
+
664
+        foreach ( $fees_processor->fees as $fee ) {
665
+            $this->add_fee( $fee );
666
+        }
667
+
668
+        do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
669
+    }
670
+
671
+    /**
672
+     * Adds a fee to the submission.
673
+     *
674
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
675
+     * @since 1.0.19
676
+     */
677
+    public function add_fee( $fee ) {
678
+
679
+        $this->fees[ $fee['name'] ]         = $fee;
680
+        $this->totals['fees']['initial']   += wpinv_sanitize_amount( $fee['initial_fee'] );
681
+        $this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] );
682
+
683
+    }
684
+
685
+    /**
686
+     * Removes a fee from the submission.
687
+     *
688
+     * @since 1.0.19
689
+     */
690
+    public function remove_fee( $name ) {
691
+
692
+        if ( isset( $this->fees[ $name ] ) ) {
693
+            $this->totals['fees']['initial']   -= $this->fees[ $name ]['initial_fee'];
694
+            $this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee'];
695
+            unset( $this->fees[ $name ] );
696
+        }
697
+
698
+    }
699
+
700
+    /**
701
+     * Returns the fees.
702
+     *
703
+     * @since 1.0.19
704
+     */
705
+    public function get_fee() {
706
+        return $this->totals['fees']['initial'];
707
+    }
708
+
709
+    /**
710
+     * Returns the recurring fees.
711
+     *
712
+     * @since 1.0.19
713
+     */
714
+    public function get_recurring_fee() {
715
+        return $this->totals['fees']['recurring'];
716
+    }
717
+
718
+    /**
719
+     * Returns all fees.
720
+     *
721
+     * @since 1.0.19
722
+     */
723
+    public function get_fees() {
724
+        return $this->fees;
725
+    }
726
+
727
+    /**
728
+     * Checks if there are any fees for the form.
729
+     *
730
+     * @return bool
731
+     * @since 1.0.19
732
+     */
733
+    public function has_fees() {
734
+        return count( $this->fees ) !== 0;
735
+    }
736
+
737
+    /*
738 738
 	|--------------------------------------------------------------------------
739 739
 	| MISC
740 740
 	|--------------------------------------------------------------------------
@@ -742,119 +742,119 @@  discard block
 block discarded – undo
742 742
 	| Extra submission functions.
743 743
     */
744 744
 
745
-	/**
746
-	 * Checks if this is the initial fetch.
747
-	 *
748
-	 * @return bool
749
-	 * @since 1.0.19
750
-	 */
751
-	public function is_initial_fetch() {
752
-		return empty( $this->data['initial_state'] );
753
-	}
754
-
755
-	/**
756
-	 * Returns the total amount to collect for this submission.
757
-	 *
758
-	 * @since 1.0.19
759
-	 */
760
-	public function get_total() {
761
-		$total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount();
762
-		return max( $total, 0 );
763
-	}
764
-
765
-	/**
766
-	 * Returns the recurring total amount to collect for this submission.
767
-	 *
768
-	 * @since 1.0.19
769
-	 */
770
-	public function get_recurring_total() {
771
-		$total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount();
772
-		return max( $total, 0 );
773
-	}
774
-
775
-	/**
776
-	 * Whether payment details should be collected for this submission.
777
-	 *
778
-	 * @since 1.0.19
779
-	 */
780
-	public function should_collect_payment_details() {
781
-		$initial   = $this->get_total();
782
-		$recurring = $this->get_recurring_total();
783
-
784
-		if ( $this->has_recurring == 0 ) {
785
-			$recurring = 0;
786
-		}
787
-
788
-		$collect = $initial > 0 || $recurring > 0;
789
-		return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this  );
790
-	}
791
-
792
-	/**
793
-	 * Returns the billing email of the user.
794
-	 *
795
-	 * @since 1.0.19
796
-	 */
797
-	public function get_billing_email() {
798
-		return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this  );
799
-	}
800
-
801
-	/**
802
-	 * Checks if the submitter has a billing email.
803
-	 *
804
-	 * @since 1.0.19
805
-	 */
806
-	public function has_billing_email() {
807
-		$billing_email = $this->get_billing_email();
808
-		return ! empty( $billing_email ) && is_email( $billing_email );
809
-	}
810
-
811
-	/**
812
-	 * Returns the appropriate currency for the submission.
813
-	 *
814
-	 * @since 1.0.19
815
-	 * @return string
816
-	 */
817
-	public function get_currency() {
818
-		return $this->has_invoice() ? $this->invoice->get_currency() : wpinv_get_currency();
819
-    }
820
-
821
-    /**
822
-	 * Returns the raw submission data.
823
-	 *
824
-	 * @since 1.0.19
825
-	 * @return array
826
-	 */
827
-	public function get_data() {
828
-		return $this->data;
829
-	}
830
-
831
-	/**
832
-	 * Returns a field from the submission data
833
-	 *
834
-	 * @param string $field
835
-	 * @since 1.0.19
836
-	 * @return mixed|null
837
-	 */
838
-	public function get_field( $field, $sub_array_key = null ) {
839
-		return getpaid_get_array_field( $this->data, $field, $sub_array_key );
840
-	}
841
-
842
-	/**
843
-	 * Checks if a required field is set.
844
-	 *
845
-	 * @since 1.0.19
846
-	 */
847
-	public function is_required_field_set( $field ) {
848
-		return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
849
-	}
850
-
851
-	/**
852
-	 * Formats an amount
853
-	 *
854
-	 * @since 1.0.19
855
-	 */
856
-	public function format_amount( $amount ) {
857
-		return wpinv_price( $amount, $this->get_currency() );
858
-	}
745
+    /**
746
+     * Checks if this is the initial fetch.
747
+     *
748
+     * @return bool
749
+     * @since 1.0.19
750
+     */
751
+    public function is_initial_fetch() {
752
+        return empty( $this->data['initial_state'] );
753
+    }
754
+
755
+    /**
756
+     * Returns the total amount to collect for this submission.
757
+     *
758
+     * @since 1.0.19
759
+     */
760
+    public function get_total() {
761
+        $total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount();
762
+        return max( $total, 0 );
763
+    }
764
+
765
+    /**
766
+     * Returns the recurring total amount to collect for this submission.
767
+     *
768
+     * @since 1.0.19
769
+     */
770
+    public function get_recurring_total() {
771
+        $total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount();
772
+        return max( $total, 0 );
773
+    }
774
+
775
+    /**
776
+     * Whether payment details should be collected for this submission.
777
+     *
778
+     * @since 1.0.19
779
+     */
780
+    public function should_collect_payment_details() {
781
+        $initial   = $this->get_total();
782
+        $recurring = $this->get_recurring_total();
783
+
784
+        if ( $this->has_recurring == 0 ) {
785
+            $recurring = 0;
786
+        }
787
+
788
+        $collect = $initial > 0 || $recurring > 0;
789
+        return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this  );
790
+    }
791
+
792
+    /**
793
+     * Returns the billing email of the user.
794
+     *
795
+     * @since 1.0.19
796
+     */
797
+    public function get_billing_email() {
798
+        return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this  );
799
+    }
800
+
801
+    /**
802
+     * Checks if the submitter has a billing email.
803
+     *
804
+     * @since 1.0.19
805
+     */
806
+    public function has_billing_email() {
807
+        $billing_email = $this->get_billing_email();
808
+        return ! empty( $billing_email ) && is_email( $billing_email );
809
+    }
810
+
811
+    /**
812
+     * Returns the appropriate currency for the submission.
813
+     *
814
+     * @since 1.0.19
815
+     * @return string
816
+     */
817
+    public function get_currency() {
818
+        return $this->has_invoice() ? $this->invoice->get_currency() : wpinv_get_currency();
819
+    }
820
+
821
+    /**
822
+     * Returns the raw submission data.
823
+     *
824
+     * @since 1.0.19
825
+     * @return array
826
+     */
827
+    public function get_data() {
828
+        return $this->data;
829
+    }
830
+
831
+    /**
832
+     * Returns a field from the submission data
833
+     *
834
+     * @param string $field
835
+     * @since 1.0.19
836
+     * @return mixed|null
837
+     */
838
+    public function get_field( $field, $sub_array_key = null ) {
839
+        return getpaid_get_array_field( $this->data, $field, $sub_array_key );
840
+    }
841
+
842
+    /**
843
+     * Checks if a required field is set.
844
+     *
845
+     * @since 1.0.19
846
+     */
847
+    public function is_required_field_set( $field ) {
848
+        return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
849
+    }
850
+
851
+    /**
852
+     * Formats an amount
853
+     *
854
+     * @since 1.0.19
855
+     */
856
+    public function format_amount( $amount ) {
857
+        return wpinv_price( $amount, $this->get_currency() );
858
+    }
859 859
 
860 860
 }
Please login to merge, or discard this patch.
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 		$this->state   = wpinv_get_default_state();
135 135
 
136 136
 		// Do we have an actual submission?
137
-		if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
138
-			$this->load_data( $_POST );
137
+		if (isset($_POST['getpaid_payment_form_submission'])) {
138
+			$this->load_data($_POST);
139 139
 		}
140 140
 
141 141
 	}
@@ -145,19 +145,19 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param array $data
147 147
 	 */
148
-	public function load_data( $data ) {
148
+	public function load_data($data) {
149 149
 
150 150
 		// Remove slashes from the submitted data...
151
-		$data       = wp_unslash( $data );
151
+		$data       = wp_unslash($data);
152 152
 
153 153
 		// Allow plugins to filter the data.
154
-		$data       = apply_filters( 'getpaid_submission_data', $data, $this );
154
+		$data       = apply_filters('getpaid_submission_data', $data, $this);
155 155
 
156 156
 		// Cache it...
157 157
 		$this->data = $data;
158 158
 
159 159
 		// Then generate a unique id from the data.
160
-		$this->id   = md5( wp_json_encode( $data ) );
160
+		$this->id   = md5(wp_json_encode($data));
161 161
 
162 162
 		// Finally, process the submission.
163 163
 		try {
@@ -167,26 +167,26 @@  discard block
 block discarded – undo
167 167
 			$processors = apply_filters(
168 168
 				'getpaid_payment_form_submission_processors',
169 169
 				array(
170
-					array( $this, 'process_payment_form' ),
171
-					array( $this, 'process_invoice' ),
172
-					array( $this, 'process_fees' ),
173
-					array( $this, 'process_items' ),
174
-					array( $this, 'process_discount' ),
175
-					array( $this, 'process_taxes' ),
170
+					array($this, 'process_payment_form'),
171
+					array($this, 'process_invoice'),
172
+					array($this, 'process_fees'),
173
+					array($this, 'process_items'),
174
+					array($this, 'process_discount'),
175
+					array($this, 'process_taxes'),
176 176
 				),
177 177
 				$this		
178 178
 			);
179 179
 
180
-			foreach ( $processors as $processor ) {
181
-				call_user_func_array( $processor, array( &$this ) );
180
+			foreach ($processors as $processor) {
181
+				call_user_func_array($processor, array(&$this));
182 182
 			}
183 183
 
184
-		} catch ( Exception $e ) {
184
+		} catch (Exception $e) {
185 185
 			$this->last_error = $e->getMessage();
186 186
 		}
187 187
 
188 188
 		// Fired when we are done processing a submission.
189
-		do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
189
+		do_action_ref_array('getpaid_process_submission', array(&$this));
190 190
 
191 191
 	}
192 192
 
@@ -207,18 +207,18 @@  discard block
 block discarded – undo
207 207
 	public function process_payment_form() {
208 208
 
209 209
 		// Every submission needs an active payment form.
210
-		if ( empty( $this->data['form_id'] ) ) {
211
-			throw new Exception( __( 'Missing payment form', 'invoicing' ) );
210
+		if (empty($this->data['form_id'])) {
211
+			throw new Exception(__('Missing payment form', 'invoicing'));
212 212
 		}
213 213
 
214 214
 		// Fetch the payment form.
215
-		$this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] );
215
+		$this->payment_form = new GetPaid_Payment_Form($this->data['form_id']);
216 216
 
217
-		if ( ! $this->payment_form->is_active() ) {
218
-			throw new Exception( __( 'Payment form not active', 'invoicing' ) );
217
+		if (!$this->payment_form->is_active()) {
218
+			throw new Exception(__('Payment form not active', 'invoicing'));
219 219
 		}
220 220
 
221
-		do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) );
221
+		do_action_ref_array('getpaid_submissions_process_payment_form', array(&$this));
222 222
 	}
223 223
 
224 224
     /**
@@ -248,30 +248,30 @@  discard block
 block discarded – undo
248 248
 	public function process_invoice() {
249 249
 
250 250
 		// Abort if there is no invoice.
251
-		if ( empty( $this->data['invoice_id'] ) ) {
251
+		if (empty($this->data['invoice_id'])) {
252 252
 			return;
253 253
 		}
254 254
 
255 255
 		// If the submission is for an existing invoice, ensure that it exists
256 256
 		// and that it is not paid for.
257
-		$invoice = wpinv_get_invoice( $this->data['invoice_id'] );
257
+		$invoice = wpinv_get_invoice($this->data['invoice_id']);
258 258
 
259
-        if ( empty( $invoice ) ) {
260
-			throw new Exception( __( 'Invalid invoice', 'invoicing' ) );
259
+        if (empty($invoice)) {
260
+			throw new Exception(__('Invalid invoice', 'invoicing'));
261 261
 		}
262 262
 
263
-		if ( $invoice->is_paid() ) {
264
-			throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) );
263
+		if ($invoice->is_paid()) {
264
+			throw new Exception(__('This invoice is already paid for.', 'invoicing'));
265 265
 		}
266 266
 
267
-		$this->payment_form->set_items( $invoice->get_items() );
267
+		$this->payment_form->set_items($invoice->get_items());
268 268
 		$this->payment_form->invoice = $invoice;
269 269
 
270 270
 		$this->country = $invoice->get_country();
271 271
 		$this->state   = $invoice->get_state();
272 272
 		$this->invoice = $invoice;
273 273
 
274
-		do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) );
274
+		do_action_ref_array('getpaid_submissions_process_invoice', array(&$this));
275 275
 	}
276 276
 
277 277
 	/**
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @return bool
292 292
 	 */
293 293
 	public function has_invoice() {
294
-		return ! empty( $this->invoice );
294
+		return !empty($this->invoice);
295 295
 	}
296 296
 
297 297
 	/*
@@ -310,13 +310,13 @@  discard block
 block discarded – undo
310 310
 	 */
311 311
 	public function process_items() {
312 312
 
313
-		$processor = new GetPaid_Payment_Form_Submission_Items( $this );
313
+		$processor = new GetPaid_Payment_Form_Submission_Items($this);
314 314
 
315
-		foreach ( $processor->items as $item ) {
316
-			$this->add_item( $item );
315
+		foreach ($processor->items as $item) {
316
+			$this->add_item($item);
317 317
 		}
318 318
 
319
-		do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) );
319
+		do_action_ref_array('getpaid_submissions_process_items', array(&$this));
320 320
 	}
321 321
 
322 322
 	/**
@@ -325,18 +325,18 @@  discard block
 block discarded – undo
325 325
 	 * @since 1.0.19
326 326
 	 * @param GetPaid_Form_Item $item
327 327
 	 */
328
-	public function add_item( $item ) {
328
+	public function add_item($item) {
329 329
 
330 330
 		// Make sure that it is available for purchase.
331
-		if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) {
331
+		if (!$item->can_purchase() || isset($this->items[$item->get_id()])) {
332 332
 			return;
333 333
 		}
334 334
 
335 335
 		// Each submission can only contain one recurring item.
336
-		if ( $item->is_recurring() ) {
336
+		if ($item->is_recurring()) {
337 337
 
338
-			if ( $this->has_recurring != 0 ) {
339
-				throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) );
338
+			if ($this->has_recurring != 0) {
339
+				throw new Exception(__('You can only buy one recurring item at a time.', 'invoicing'));
340 340
 			}
341 341
 
342 342
 			$this->has_recurring = $item->get_id();
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 		}
345 345
 
346 346
 		// Update the items and totals.
347
-		$this->items[ $item->get_id() ]         = $item;
347
+		$this->items[$item->get_id()]         = $item;
348 348
 		$this->totals['subtotal']['initial']   += $item->get_sub_total();
349 349
 		$this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total();
350 350
 
@@ -358,17 +358,17 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
 	 * @since 1.0.19
360 360
 	 */
361
-	public function remove_item( $item_id ) {
361
+	public function remove_item($item_id) {
362 362
 
363
-		if ( isset( $this->items[ $item_id ] ) ) {
364
-			$this->totals['subtotal']['initial']   -= $this->items[ $item_id ]->get_sub_total();
365
-			$this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total();
363
+		if (isset($this->items[$item_id])) {
364
+			$this->totals['subtotal']['initial']   -= $this->items[$item_id]->get_sub_total();
365
+			$this->totals['subtotal']['recurring'] -= $this->items[$item_id]->get_recurring_sub_total();
366 366
 
367
-			if ( $this->items[ $item_id ]->is_recurring() ) {
367
+			if ($this->items[$item_id]->is_recurring()) {
368 368
 				$this->has_recurring = 0;
369 369
 			}
370 370
 
371
-			unset( $this->items[ $item_id ] );
371
+			unset($this->items[$item_id]);
372 372
 		}
373 373
 
374 374
 	}
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 */
381 381
 	public function get_subtotal() {
382 382
 
383
-		if ( wpinv_prices_include_tax() ) {
383
+		if (wpinv_prices_include_tax()) {
384 384
 			return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial'];
385 385
 		}
386 386
 
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	 */
395 395
 	public function get_recurring_subtotal() {
396 396
 
397
-		if ( wpinv_prices_include_tax() ) {
397
+		if (wpinv_prices_include_tax()) {
398 398
 			return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring'];
399 399
 		}
400 400
 
@@ -428,39 +428,39 @@  discard block
 block discarded – undo
428 428
 	public function process_taxes() {
429 429
 
430 430
 		// Abort if we're not using taxes.
431
-		if ( ! $this->use_taxes() ) {
431
+		if (!$this->use_taxes()) {
432 432
 			return;
433 433
 		}
434 434
 
435 435
 		// If a custom country && state has been passed in, use it to calculate taxes.
436
-		$country = $this->get_field( 'wpinv_country', 'billing' );
437
-		if ( ! empty( $country ) ) {
436
+		$country = $this->get_field('wpinv_country', 'billing');
437
+		if (!empty($country)) {
438 438
 			$this->country = $country;
439 439
 		}
440 440
 
441
-		$state = $this->get_field( 'wpinv_state', 'billing' );
442
-		if ( ! empty( $state ) ) {
441
+		$state = $this->get_field('wpinv_state', 'billing');
442
+		if (!empty($state)) {
443 443
 			$this->state = $state;
444 444
 		}
445 445
 
446 446
 		// Confirm if the provided country and the ip country are similar.
447
-		$address_confirmed = $this->get_field( 'confirm-address' );
448
-		if ( wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty( $address_confirmed ) ) {
449
-			throw new Exception( __( 'The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing' ) );
447
+		$address_confirmed = $this->get_field('confirm-address');
448
+		if (wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty($address_confirmed)) {
449
+			throw new Exception(__('The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing'));
450 450
 		}
451 451
 
452 452
 		// Abort if the country is not taxable.
453
-		if ( ! wpinv_is_country_taxable( $this->country ) ) {
453
+		if (!wpinv_is_country_taxable($this->country)) {
454 454
 			return;
455 455
 		}
456 456
 
457
-		$processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
457
+		$processor = new GetPaid_Payment_Form_Submission_Taxes($this);
458 458
 
459
-		foreach ( $processor->taxes as $tax ) {
460
-			$this->add_tax( $tax );
459
+		foreach ($processor->taxes as $tax) {
460
+			$this->add_tax($tax);
461 461
 		}
462 462
 
463
-		do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
463
+		do_action_ref_array('getpaid_submissions_process_taxes', array(&$this));
464 464
 	}
465 465
 
466 466
 	/**
@@ -469,16 +469,16 @@  discard block
 block discarded – undo
469 469
 	 * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
470 470
 	 * @since 1.0.19
471 471
 	 */
472
-	public function add_tax( $tax ) {
472
+	public function add_tax($tax) {
473 473
 
474
-		if ( wpinv_round_tax_per_tax_rate() ) {
475
-			$tax['initial_tax']   = wpinv_round_amount( $tax['initial_tax'] );
476
-			$tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] );
474
+		if (wpinv_round_tax_per_tax_rate()) {
475
+			$tax['initial_tax']   = wpinv_round_amount($tax['initial_tax']);
476
+			$tax['recurring_tax'] = wpinv_round_amount($tax['recurring_tax']);
477 477
 		}
478 478
 
479
-		$this->taxes[ $tax['name'] ]         = $tax;
480
-		$this->totals['taxes']['initial']   += wpinv_sanitize_amount( $tax['initial_tax'] );
481
-		$this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] );
479
+		$this->taxes[$tax['name']]         = $tax;
480
+		$this->totals['taxes']['initial']   += wpinv_sanitize_amount($tax['initial_tax']);
481
+		$this->totals['taxes']['recurring'] += wpinv_sanitize_amount($tax['recurring_tax']);
482 482
 
483 483
 	}
484 484
 
@@ -487,12 +487,12 @@  discard block
 block discarded – undo
487 487
 	 *
488 488
 	 * @since 1.0.19
489 489
 	 */
490
-	public function remove_tax( $tax_name ) {
490
+	public function remove_tax($tax_name) {
491 491
 
492
-		if ( isset( $this->taxes[ $tax_name ] ) ) {
493
-			$this->totals['taxes']['initial']   -= $this->taxes[ $tax_name ]['initial_tax'];
494
-			$this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax'];
495
-			unset( $this->taxes[ $tax_name ] );
492
+		if (isset($this->taxes[$tax_name])) {
493
+			$this->totals['taxes']['initial']   -= $this->taxes[$tax_name]['initial_tax'];
494
+			$this->totals['taxes']['recurring'] -= $this->taxes[$tax_name]['recurring_tax'];
495
+			unset($this->taxes[$tax_name]);
496 496
 		}
497 497
 
498 498
 	}
@@ -506,11 +506,11 @@  discard block
 block discarded – undo
506 506
 
507 507
 		$use_taxes = wpinv_use_taxes();
508 508
 
509
-		if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
509
+		if ($this->has_invoice() && !$this->invoice->is_taxable()) {
510 510
 			$use_taxes = false;
511 511
 		}
512 512
 
513
-		return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
513
+		return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this);
514 514
 
515 515
 	}
516 516
 
@@ -559,13 +559,13 @@  discard block
 block discarded – undo
559 559
 
560 560
 		$initial_total    = $this->get_subtotal() + $this->get_fee() + $this->get_tax();
561 561
 		$recurring_total  = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax();
562
-		$processor        = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total );
562
+		$processor        = new GetPaid_Payment_Form_Submission_Discount($this, $initial_total, $recurring_total);
563 563
 
564
-		foreach ( $processor->discounts as $discount ) {
565
-			$this->add_discount( $discount );
564
+		foreach ($processor->discounts as $discount) {
565
+			$this->add_discount($discount);
566 566
 		}
567 567
 
568
-		do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
568
+		do_action_ref_array('getpaid_submissions_process_discounts', array(&$this));
569 569
 	}
570 570
 
571 571
 	/**
@@ -574,10 +574,10 @@  discard block
 block discarded – undo
574 574
 	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
575 575
 	 * @since 1.0.19
576 576
 	 */
577
-	public function add_discount( $discount ) {
578
-		$this->discounts[ $discount['name'] ]   = $discount;
579
-		$this->totals['discount']['initial']   += wpinv_sanitize_amount( $discount['initial_discount'] );
580
-		$this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] );
577
+	public function add_discount($discount) {
578
+		$this->discounts[$discount['name']]   = $discount;
579
+		$this->totals['discount']['initial']   += wpinv_sanitize_amount($discount['initial_discount']);
580
+		$this->totals['discount']['recurring'] += wpinv_sanitize_amount($discount['recurring_discount']);
581 581
 	}
582 582
 
583 583
 	/**
@@ -585,12 +585,12 @@  discard block
 block discarded – undo
585 585
 	 *
586 586
 	 * @since 1.0.19
587 587
 	 */
588
-	public function remove_discount( $name ) {
588
+	public function remove_discount($name) {
589 589
 
590
-		if ( isset( $this->discounts[ $name ] ) ) {
591
-			$this->totals['discount']['initial']   -= $this->discounts[ $name ]['initial_discount'];
592
-			$this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount'];
593
-			unset( $this->discounts[ $name ] );
590
+		if (isset($this->discounts[$name])) {
591
+			$this->totals['discount']['initial']   -= $this->discounts[$name]['initial_discount'];
592
+			$this->totals['discount']['recurring'] -= $this->discounts[$name]['recurring_discount'];
593
+			unset($this->discounts[$name]);
594 594
 		}
595 595
 
596 596
 	}
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 	 * @return bool
603 603
 	 */
604 604
 	public function has_discount_code() {
605
-		return ! empty( $this->discounts['discount_code'] );
605
+		return !empty($this->discounts['discount_code']);
606 606
 	}
607 607
 
608 608
 	/**
@@ -659,13 +659,13 @@  discard block
 block discarded – undo
659 659
 	 */
660 660
 	public function process_fees() {
661 661
 
662
-		$fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
662
+		$fees_processor = new GetPaid_Payment_Form_Submission_Fees($this);
663 663
 
664
-		foreach ( $fees_processor->fees as $fee ) {
665
-			$this->add_fee( $fee );
664
+		foreach ($fees_processor->fees as $fee) {
665
+			$this->add_fee($fee);
666 666
 		}
667 667
 
668
-		do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
668
+		do_action_ref_array('getpaid_submissions_process_fees', array(&$this));
669 669
 	}
670 670
 
671 671
 	/**
@@ -674,11 +674,11 @@  discard block
 block discarded – undo
674 674
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
675 675
 	 * @since 1.0.19
676 676
 	 */
677
-	public function add_fee( $fee ) {
677
+	public function add_fee($fee) {
678 678
 
679
-		$this->fees[ $fee['name'] ]         = $fee;
680
-		$this->totals['fees']['initial']   += wpinv_sanitize_amount( $fee['initial_fee'] );
681
-		$this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] );
679
+		$this->fees[$fee['name']]         = $fee;
680
+		$this->totals['fees']['initial']   += wpinv_sanitize_amount($fee['initial_fee']);
681
+		$this->totals['fees']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']);
682 682
 
683 683
 	}
684 684
 
@@ -687,12 +687,12 @@  discard block
 block discarded – undo
687 687
 	 *
688 688
 	 * @since 1.0.19
689 689
 	 */
690
-	public function remove_fee( $name ) {
690
+	public function remove_fee($name) {
691 691
 
692
-		if ( isset( $this->fees[ $name ] ) ) {
693
-			$this->totals['fees']['initial']   -= $this->fees[ $name ]['initial_fee'];
694
-			$this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee'];
695
-			unset( $this->fees[ $name ] );
692
+		if (isset($this->fees[$name])) {
693
+			$this->totals['fees']['initial']   -= $this->fees[$name]['initial_fee'];
694
+			$this->totals['fees']['recurring'] -= $this->fees[$name]['recurring_fee'];
695
+			unset($this->fees[$name]);
696 696
 		}
697 697
 
698 698
 	}
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 	 * @since 1.0.19
732 732
 	 */
733 733
 	public function has_fees() {
734
-		return count( $this->fees ) !== 0;
734
+		return count($this->fees) !== 0;
735 735
 	}
736 736
 
737 737
 	/*
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	 * @since 1.0.19
750 750
 	 */
751 751
 	public function is_initial_fetch() {
752
-		return empty( $this->data['initial_state'] );
752
+		return empty($this->data['initial_state']);
753 753
 	}
754 754
 
755 755
 	/**
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 	 */
760 760
 	public function get_total() {
761 761
 		$total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount();
762
-		return max( $total, 0 );
762
+		return max($total, 0);
763 763
 	}
764 764
 
765 765
 	/**
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 	 */
770 770
 	public function get_recurring_total() {
771 771
 		$total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount();
772
-		return max( $total, 0 );
772
+		return max($total, 0);
773 773
 	}
774 774
 
775 775
 	/**
@@ -781,12 +781,12 @@  discard block
 block discarded – undo
781 781
 		$initial   = $this->get_total();
782 782
 		$recurring = $this->get_recurring_total();
783 783
 
784
-		if ( $this->has_recurring == 0 ) {
784
+		if ($this->has_recurring == 0) {
785 785
 			$recurring = 0;
786 786
 		}
787 787
 
788 788
 		$collect = $initial > 0 || $recurring > 0;
789
-		return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this  );
789
+		return apply_filters('getpaid_submission_should_collect_payment_details', $collect, $this);
790 790
 	}
791 791
 
792 792
 	/**
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 	 * @since 1.0.19
796 796
 	 */
797 797
 	public function get_billing_email() {
798
-		return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this  );
798
+		return apply_filters('getpaid_get_submission_billing_email', $this->get_field('billing_email'), $this);
799 799
 	}
800 800
 
801 801
 	/**
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 	 */
806 806
 	public function has_billing_email() {
807 807
 		$billing_email = $this->get_billing_email();
808
-		return ! empty( $billing_email ) && is_email( $billing_email );
808
+		return !empty($billing_email) && is_email($billing_email);
809 809
 	}
810 810
 
811 811
 	/**
@@ -835,8 +835,8 @@  discard block
 block discarded – undo
835 835
 	 * @since 1.0.19
836 836
 	 * @return mixed|null
837 837
 	 */
838
-	public function get_field( $field, $sub_array_key = null ) {
839
-		return getpaid_get_array_field( $this->data, $field, $sub_array_key );
838
+	public function get_field($field, $sub_array_key = null) {
839
+		return getpaid_get_array_field($this->data, $field, $sub_array_key);
840 840
 	}
841 841
 
842 842
 	/**
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 	 *
845 845
 	 * @since 1.0.19
846 846
 	 */
847
-	public function is_required_field_set( $field ) {
848
-		return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
847
+	public function is_required_field_set($field) {
848
+		return empty($field['required']) || !empty($this->data[$field['id']]);
849 849
 	}
850 850
 
851 851
 	/**
@@ -853,8 +853,8 @@  discard block
 block discarded – undo
853 853
 	 *
854 854
 	 * @since 1.0.19
855 855
 	 */
856
-	public function format_amount( $amount ) {
857
-		return wpinv_price( $amount, $this->get_currency() );
856
+	public function format_amount($amount) {
857
+		return wpinv_price($amount, $this->get_currency());
858 858
 	}
859 859
 
860 860
 }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-bank-transfer-gateway.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'bank_transfer';
21 21
 
22
-	/**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
27
-	protected $supports = array( 'addons' );
22
+    /**
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27
+    protected $supports = array( 'addons' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
34
-	public $order = 8;
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34
+    public $order = 8;
35 35
 
36 36
     /**
37
-	 * Class constructor.
38
-	 */
39
-	public function __construct() {
37
+     * Class constructor.
38
+     */
39
+    public function __construct() {
40 40
         parent::__construct();
41 41
 
42 42
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
45 45
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
46 46
 
47
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
47
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
+        add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
51 51
 
52 52
     }
53 53
 
54 54
     /**
55
-	 * Process Payment.
56
-	 *
57
-	 *
58
-	 * @param WPInv_Invoice $invoice Invoice.
59
-	 * @param array $submission_data Posted checkout fields.
60
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
61
-	 * @return array
62
-	 */
63
-	public function process_payment( $invoice, $submission_data, $submission ) {
55
+     * Process Payment.
56
+     *
57
+     *
58
+     * @param WPInv_Invoice $invoice Invoice.
59
+     * @param array $submission_data Posted checkout fields.
60
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
61
+     * @return array
62
+     */
63
+    public function process_payment( $invoice, $submission_data, $submission ) {
64 64
 
65 65
         // Add a transaction id.
66 66
         $invoice->set_transaction_id( $invoice->generate_key('trans_') );
@@ -81,66 +81,66 @@  discard block
 block discarded – undo
81 81
     }
82 82
 
83 83
     /**
84
-	 * Output for the order received page.
85
-	 *
86
-	 * @param WPInv_Invoice $invoice Invoice.
87
-	 */
88
-	public function thankyou_page( $invoice ) {
84
+     * Output for the order received page.
85
+     *
86
+     * @param WPInv_Invoice $invoice Invoice.
87
+     */
88
+    public function thankyou_page( $invoice ) {
89 89
 
90 90
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
91 91
 
92
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
92
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
93 93
 
94 94
             if ( ! empty( $this->instructions ) ) {
95 95
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
96
-			}
96
+            }
97 97
 
98
-			$this->bank_details( $invoice );
98
+            $this->bank_details( $invoice );
99 99
 
100
-			echo '</div>';
100
+            echo '</div>';
101 101
 
102 102
         }
103 103
 
104
-	}
104
+    }
105 105
 
106 106
     /**
107
-	 * Add content to the WPI emails.
108
-	 *
109
-	 * @param WPInv_Invoice $invoice Invoice.
110
-	 * @param string     $email_type Email format: plain text or HTML.
111
-	 * @param bool     $sent_to_admin Sent to admin.
112
-	 */
113
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
107
+     * Add content to the WPI emails.
108
+     *
109
+     * @param WPInv_Invoice $invoice Invoice.
110
+     * @param string     $email_type Email format: plain text or HTML.
111
+     * @param bool     $sent_to_admin Sent to admin.
112
+     */
113
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
114 114
 
115
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
115
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
116 116
 
117
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
117
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
118 118
 
119
-			if ( $this->instructions ) {
120
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
119
+            if ( $this->instructions ) {
120
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
121 121
             }
122 122
 
123
-			$this->bank_details( $invoice );
123
+            $this->bank_details( $invoice );
124 124
 			
125
-			echo '</div>';
125
+            echo '</div>';
126 126
 
127
-		}
127
+        }
128 128
 
129 129
     }
130 130
     
131 131
     /**
132
-	 * Get bank details and place into a list format.
133
-	 *
134
-	 * @param WPInv_Invoice $invoice Invoice.
135
-	 */
136
-	protected function bank_details( $invoice ) {
132
+     * Get bank details and place into a list format.
133
+     *
134
+     * @param WPInv_Invoice $invoice Invoice.
135
+     */
136
+    protected function bank_details( $invoice ) {
137 137
 
138
-		// Get the invoice country and country $locale.
139
-		$country = $invoice->get_country();
140
-		$locale  = $this->get_country_locale();
138
+        // Get the invoice country and country $locale.
139
+        $country = $invoice->get_country();
140
+        $locale  = $this->get_country_locale();
141 141
 
142
-		// Get sortcode label in the $locale array and use appropriate one.
143
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
142
+        // Get sortcode label in the $locale array and use appropriate one.
143
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
144 144
 
145 145
         $bank_fields = array(
146 146
             'ac_name'     => __( 'Account Name', 'invoicing' ),
@@ -169,144 +169,144 @@  discard block
 block discarded – undo
169 169
             return;
170 170
         }
171 171
 
172
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
172
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
173 173
 
174
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
174
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
175 175
 
176
-		foreach ( $bank_info as $key => $data ) {
176
+        foreach ( $bank_info as $key => $data ) {
177 177
 
178
-			$key   = sanitize_html_class( $key );
179
-			$label = wp_kses_post( $data['label'] );
180
-			$value = wp_kses_post( wptexturize( $data['value'] ) );
178
+            $key   = sanitize_html_class( $key );
179
+            $label = wp_kses_post( $data['label'] );
180
+            $value = wp_kses_post( wptexturize( $data['value'] ) );
181 181
 
182
-			echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL;
183
-		}
182
+            echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL;
183
+        }
184 184
 
185
-		echo '</table>';
185
+        echo '</table>';
186 186
 
187 187
     }
188 188
     
189 189
     /**
190
-	 * Get country locale if localized.
191
-	 *
192
-	 * @return array
193
-	 */
194
-	public function get_country_locale() {
195
-
196
-		if ( empty( $this->locale ) ) {
197
-
198
-			// Locale information to be used - only those that are not 'Sort Code'.
199
-			$this->locale = apply_filters(
200
-				'getpaid_get_bank_transfer_locale',
201
-				array(
202
-					'AU' => array(
203
-						'sortcode' => array(
204
-							'label' => __( 'BSB', 'invoicing' ),
205
-						),
206
-					),
207
-					'CA' => array(
208
-						'sortcode' => array(
209
-							'label' => __( 'Bank transit number', 'invoicing' ),
210
-						),
211
-					),
212
-					'IN' => array(
213
-						'sortcode' => array(
214
-							'label' => __( 'IFSC', 'invoicing' ),
215
-						),
216
-					),
217
-					'IT' => array(
218
-						'sortcode' => array(
219
-							'label' => __( 'Branch sort', 'invoicing' ),
220
-						),
221
-					),
222
-					'NZ' => array(
223
-						'sortcode' => array(
224
-							'label' => __( 'Bank code', 'invoicing' ),
225
-						),
226
-					),
227
-					'SE' => array(
228
-						'sortcode' => array(
229
-							'label' => __( 'Bank code', 'invoicing' ),
230
-						),
231
-					),
232
-					'US' => array(
233
-						'sortcode' => array(
234
-							'label' => __( 'Routing number', 'invoicing' ),
235
-						),
236
-					),
237
-					'ZA' => array(
238
-						'sortcode' => array(
239
-							'label' => __( 'Branch code', 'invoicing' ),
240
-						),
241
-					),
242
-				)
243
-			);
244
-
245
-		}
246
-
247
-		return $this->locale;
248
-
249
-	}
250
-
251
-	/**
252
-	 * Filters the gateway settings.
253
-	 * 
254
-	 * @param array $admin_settings
255
-	 */
256
-	public function admin_settings( $admin_settings ) {
190
+     * Get country locale if localized.
191
+     *
192
+     * @return array
193
+     */
194
+    public function get_country_locale() {
195
+
196
+        if ( empty( $this->locale ) ) {
197
+
198
+            // Locale information to be used - only those that are not 'Sort Code'.
199
+            $this->locale = apply_filters(
200
+                'getpaid_get_bank_transfer_locale',
201
+                array(
202
+                    'AU' => array(
203
+                        'sortcode' => array(
204
+                            'label' => __( 'BSB', 'invoicing' ),
205
+                        ),
206
+                    ),
207
+                    'CA' => array(
208
+                        'sortcode' => array(
209
+                            'label' => __( 'Bank transit number', 'invoicing' ),
210
+                        ),
211
+                    ),
212
+                    'IN' => array(
213
+                        'sortcode' => array(
214
+                            'label' => __( 'IFSC', 'invoicing' ),
215
+                        ),
216
+                    ),
217
+                    'IT' => array(
218
+                        'sortcode' => array(
219
+                            'label' => __( 'Branch sort', 'invoicing' ),
220
+                        ),
221
+                    ),
222
+                    'NZ' => array(
223
+                        'sortcode' => array(
224
+                            'label' => __( 'Bank code', 'invoicing' ),
225
+                        ),
226
+                    ),
227
+                    'SE' => array(
228
+                        'sortcode' => array(
229
+                            'label' => __( 'Bank code', 'invoicing' ),
230
+                        ),
231
+                    ),
232
+                    'US' => array(
233
+                        'sortcode' => array(
234
+                            'label' => __( 'Routing number', 'invoicing' ),
235
+                        ),
236
+                    ),
237
+                    'ZA' => array(
238
+                        'sortcode' => array(
239
+                            'label' => __( 'Branch code', 'invoicing' ),
240
+                        ),
241
+                    ),
242
+                )
243
+            );
244
+
245
+        }
246
+
247
+        return $this->locale;
248
+
249
+    }
250
+
251
+    /**
252
+     * Filters the gateway settings.
253
+     * 
254
+     * @param array $admin_settings
255
+     */
256
+    public function admin_settings( $admin_settings ) {
257 257
 
258 258
         $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
259
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
259
+        $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
260 260
 
261
-		$locale  = $this->get_country_locale();
261
+        $locale  = $this->get_country_locale();
262 262
 
263
-		// Get sortcode label in the $locale array and use appropriate one.
264
-		$country  = wpinv_default_billing_country();
265
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
263
+        // Get sortcode label in the $locale array and use appropriate one.
264
+        $country  = wpinv_default_billing_country();
265
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
266 266
 
267
-		$admin_settings['bank_transfer_ac_name'] = array(
267
+        $admin_settings['bank_transfer_ac_name'] = array(
268 268
             'type' => 'text',
269 269
             'id'   => 'bank_transfer_ac_name',
270 270
             'name' => __( 'Account Name', 'invoicing' ),
271
-		);
271
+        );
272 272
 		
273
-		$admin_settings['bank_transfer_ac_no'] = array(
273
+        $admin_settings['bank_transfer_ac_no'] = array(
274 274
             'type' => 'text',
275 275
             'id'   => 'bank_transfer_ac_no',
276 276
             'name' => __( 'Account Number', 'invoicing' ),
277
-		);
277
+        );
278 278
 		
279
-		$admin_settings['bank_transfer_bank_name'] = array(
279
+        $admin_settings['bank_transfer_bank_name'] = array(
280 280
             'type' => 'text',
281 281
             'id'   => 'bank_transfer_bank_name',
282 282
             'name' => __( 'Bank Name', 'invoicing' ),
283
-		);
283
+        );
284 284
 
285
-		$admin_settings['bank_transfer_ifsc'] = array(
285
+        $admin_settings['bank_transfer_ifsc'] = array(
286 286
             'type' => 'text',
287 287
             'id'   => 'bank_transfer_ifsc',
288 288
             'name' => __( 'IFSC Code', 'invoicing' ),
289
-		);
289
+        );
290 290
 
291
-		$admin_settings['bank_transfer_iban'] = array(
291
+        $admin_settings['bank_transfer_iban'] = array(
292 292
             'type' => 'text',
293 293
             'id'   => 'bank_transfer_iban',
294 294
             'name' => __( 'IBAN', 'invoicing' ),
295
-		);
295
+        );
296 296
 
297
-		$admin_settings['bank_transfer_bic'] = array(
297
+        $admin_settings['bank_transfer_bic'] = array(
298 298
             'type' => 'text',
299 299
             'id'   => 'bank_transfer_bic',
300 300
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
301
-		);
301
+        );
302 302
 		
303
-		$admin_settings['bank_transfer_sort_code'] = array(
304
-			'type' => 'text',
305
-			'id'   => 'bank_transfer_sort_code',
306
-			'name' => $sortcode,
307
-		);
303
+        $admin_settings['bank_transfer_sort_code'] = array(
304
+            'type' => 'text',
305
+            'id'   => 'bank_transfer_sort_code',
306
+            'name' => $sortcode,
307
+        );
308 308
 
309
-		$admin_settings['bank_transfer_info'] = array(
309
+        $admin_settings['bank_transfer_info'] = array(
310 310
             'id'   => 'bank_transfer_info',
311 311
             'name' => __( 'Instructions', 'invoicing' ),
312 312
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -316,17 +316,17 @@  discard block
 block discarded – undo
316 316
             'rows' => 5
317 317
         );
318 318
 
319
-		return $admin_settings;
320
-	}
319
+        return $admin_settings;
320
+    }
321 321
 
322
-	/**
323
-	 * Processes invoice addons.
324
-	 *
325
-	 * @param WPInv_Invoice $invoice
326
-	 * @param GetPaid_Form_Item[] $items
327
-	 * @return WPInv_Invoice
328
-	 */
329
-	public function process_addons( $invoice, $items ) {
322
+    /**
323
+     * Processes invoice addons.
324
+     *
325
+     * @param WPInv_Invoice $invoice
326
+     * @param GetPaid_Form_Item[] $items
327
+     * @return WPInv_Invoice
328
+     */
329
+    public function process_addons( $invoice, $items ) {
330 330
 
331 331
         foreach ( $items as $item ) {
332 332
             $invoice->add_item( $item );
@@ -334,6 +334,6 @@  discard block
 block discarded – undo
334 334
 
335 335
         $invoice->recalculate_total();
336 336
         $invoice->save();
337
-	}
337
+    }
338 338
 
339 339
 }
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 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
  * Bank transfer Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-	protected $supports = array( 'addons' );
27
+	protected $supports = array('addons');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
 	public function __construct() {
40 40
         parent::__construct();
41 41
 
42
-        $this->title                = __( 'Direct bank transfer', 'invoicing' );
43
-        $this->method_title         = __( 'Bank transfer', 'invoicing' );
44
-        $this->checkout_button_text = __( 'Proceed', 'invoicing' );
45
-        $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
42
+        $this->title                = __('Direct bank transfer', 'invoicing');
43
+        $this->method_title         = __('Bank transfer', 'invoicing');
44
+        $this->checkout_button_text = __('Proceed', 'invoicing');
45
+        $this->instructions         = apply_filters('wpinv_bank_instructions', $this->get_option('info'));
46 46
 
47
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
47
+		add_action('wpinv_receipt_end', array($this, 'thankyou_page'));
48
+		add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40);
49
+		add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11);
50
+		add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3);
51 51
 
52 52
     }
53 53
 
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
61 61
 	 * @return array
62 62
 	 */
63
-	public function process_payment( $invoice, $submission_data, $submission ) {
63
+	public function process_payment($invoice, $submission_data, $submission) {
64 64
 
65 65
         // Add a transaction id.
66
-        $invoice->set_transaction_id( $invoice->generate_key('trans_') );
66
+        $invoice->set_transaction_id($invoice->generate_key('trans_'));
67 67
 
68 68
         // Set it as pending payment.
69
-        if ( ! $invoice->needs_payment() ) {
69
+        if (!$invoice->needs_payment()) {
70 70
             $invoice->mark_paid();
71
-        } else if ( ! $invoice->is_paid() ) {
72
-            $invoice->set_status( 'wpi-onhold' );
71
+        } else if (!$invoice->is_paid()) {
72
+            $invoice->set_status('wpi-onhold');
73 73
         }
74 74
 
75 75
         // Save it.
76 76
         $invoice->save();
77 77
 
78 78
         // Send to the success page.
79
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
79
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
80 80
 
81 81
     }
82 82
 
@@ -85,17 +85,17 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @param WPInv_Invoice $invoice Invoice.
87 87
 	 */
88
-	public function thankyou_page( $invoice ) {
88
+	public function thankyou_page($invoice) {
89 89
 
90
-        if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
90
+        if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
91 91
 
92 92
 			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
93 93
 
94
-            if ( ! empty( $this->instructions ) ) {
95
-                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
94
+            if (!empty($this->instructions)) {
95
+                echo wp_kses_post(wpautop(wptexturize($this->instructions)));
96 96
 			}
97 97
 
98
-			$this->bank_details( $invoice );
98
+			$this->bank_details($invoice);
99 99
 
100 100
 			echo '</div>';
101 101
 
@@ -110,17 +110,17 @@  discard block
 block discarded – undo
110 110
 	 * @param string     $email_type Email format: plain text or HTML.
111 111
 	 * @param bool     $sent_to_admin Sent to admin.
112 112
 	 */
113
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
113
+	public function email_instructions($invoice, $email_type, $sent_to_admin) {
114 114
 
115
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
115
+		if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
116 116
 
117 117
 			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
118 118
 
119
-			if ( $this->instructions ) {
120
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
119
+			if ($this->instructions) {
120
+				echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL);
121 121
             }
122 122
 
123
-			$this->bank_details( $invoice );
123
+			$this->bank_details($invoice);
124 124
 			
125 125
 			echo '</div>';
126 126
 
@@ -133,51 +133,51 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param WPInv_Invoice $invoice Invoice.
135 135
 	 */
136
-	protected function bank_details( $invoice ) {
136
+	protected function bank_details($invoice) {
137 137
 
138 138
 		// Get the invoice country and country $locale.
139 139
 		$country = $invoice->get_country();
140 140
 		$locale  = $this->get_country_locale();
141 141
 
142 142
 		// Get sortcode label in the $locale array and use appropriate one.
143
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
143
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
144 144
 
145 145
         $bank_fields = array(
146
-            'ac_name'     => __( 'Account Name', 'invoicing' ),
147
-            'ac_no'       => __( 'Account Number', 'invoicing' ),
148
-            'bank_name'   => __( 'Bank Name', 'invoicing' ),
149
-            'ifsc'        => __( 'IFSC code', 'invoicing' ),
150
-            'iban'        => __( 'IBAN', 'invoicing' ),
151
-            'bic'         => __( 'BIC/Swift code', 'invoicing' ),
146
+            'ac_name'     => __('Account Name', 'invoicing'),
147
+            'ac_no'       => __('Account Number', 'invoicing'),
148
+            'bank_name'   => __('Bank Name', 'invoicing'),
149
+            'ifsc'        => __('IFSC code', 'invoicing'),
150
+            'iban'        => __('IBAN', 'invoicing'),
151
+            'bic'         => __('BIC/Swift code', 'invoicing'),
152 152
             'sort_code'   => $sortcode,
153 153
         );
154 154
 
155 155
         $bank_info = array();
156 156
 
157
-        foreach ( $bank_fields as $field => $label ) {
158
-            $value = $this->get_option( $field );
157
+        foreach ($bank_fields as $field => $label) {
158
+            $value = $this->get_option($field);
159 159
 
160
-            if ( ! empty( $value ) ) {
161
-                $bank_info[$field] = array( 'label' => $label, 'value' => $value );
160
+            if (!empty($value)) {
161
+                $bank_info[$field] = array('label' => $label, 'value' => $value);
162 162
             }
163 163
 
164 164
         }
165 165
 
166
-        $bank_info = apply_filters( 'wpinv_bank_info', $bank_info );
166
+        $bank_info = apply_filters('wpinv_bank_info', $bank_info);
167 167
 
168
-        if ( empty( $bank_info ) ) {
168
+        if (empty($bank_info)) {
169 169
             return;
170 170
         }
171 171
 
172
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
172
+		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing')) . '</h3>' . PHP_EOL;
173 173
 
174 174
 		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
175 175
 
176
-		foreach ( $bank_info as $key => $data ) {
176
+		foreach ($bank_info as $key => $data) {
177 177
 
178
-			$key   = sanitize_html_class( $key );
179
-			$label = wp_kses_post( $data['label'] );
180
-			$value = wp_kses_post( wptexturize( $data['value'] ) );
178
+			$key   = sanitize_html_class($key);
179
+			$label = wp_kses_post($data['label']);
180
+			$value = wp_kses_post(wptexturize($data['value']));
181 181
 
182 182
 			echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL;
183 183
 		}
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	public function get_country_locale() {
195 195
 
196
-		if ( empty( $this->locale ) ) {
196
+		if (empty($this->locale)) {
197 197
 
198 198
 			// Locale information to be used - only those that are not 'Sort Code'.
199 199
 			$this->locale = apply_filters(
@@ -201,42 +201,42 @@  discard block
 block discarded – undo
201 201
 				array(
202 202
 					'AU' => array(
203 203
 						'sortcode' => array(
204
-							'label' => __( 'BSB', 'invoicing' ),
204
+							'label' => __('BSB', 'invoicing'),
205 205
 						),
206 206
 					),
207 207
 					'CA' => array(
208 208
 						'sortcode' => array(
209
-							'label' => __( 'Bank transit number', 'invoicing' ),
209
+							'label' => __('Bank transit number', 'invoicing'),
210 210
 						),
211 211
 					),
212 212
 					'IN' => array(
213 213
 						'sortcode' => array(
214
-							'label' => __( 'IFSC', 'invoicing' ),
214
+							'label' => __('IFSC', 'invoicing'),
215 215
 						),
216 216
 					),
217 217
 					'IT' => array(
218 218
 						'sortcode' => array(
219
-							'label' => __( 'Branch sort', 'invoicing' ),
219
+							'label' => __('Branch sort', 'invoicing'),
220 220
 						),
221 221
 					),
222 222
 					'NZ' => array(
223 223
 						'sortcode' => array(
224
-							'label' => __( 'Bank code', 'invoicing' ),
224
+							'label' => __('Bank code', 'invoicing'),
225 225
 						),
226 226
 					),
227 227
 					'SE' => array(
228 228
 						'sortcode' => array(
229
-							'label' => __( 'Bank code', 'invoicing' ),
229
+							'label' => __('Bank code', 'invoicing'),
230 230
 						),
231 231
 					),
232 232
 					'US' => array(
233 233
 						'sortcode' => array(
234
-							'label' => __( 'Routing number', 'invoicing' ),
234
+							'label' => __('Routing number', 'invoicing'),
235 235
 						),
236 236
 					),
237 237
 					'ZA' => array(
238 238
 						'sortcode' => array(
239
-							'label' => __( 'Branch code', 'invoicing' ),
239
+							'label' => __('Branch code', 'invoicing'),
240 240
 						),
241 241
 					),
242 242
 				)
@@ -253,51 +253,51 @@  discard block
 block discarded – undo
253 253
 	 * 
254 254
 	 * @param array $admin_settings
255 255
 	 */
256
-	public function admin_settings( $admin_settings ) {
256
+	public function admin_settings($admin_settings) {
257 257
 
258
-        $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
259
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
258
+        $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing');
259
+		$admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing');
260 260
 
261
-		$locale  = $this->get_country_locale();
261
+		$locale = $this->get_country_locale();
262 262
 
263 263
 		// Get sortcode label in the $locale array and use appropriate one.
264 264
 		$country  = wpinv_default_billing_country();
265
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
265
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
266 266
 
267 267
 		$admin_settings['bank_transfer_ac_name'] = array(
268 268
             'type' => 'text',
269 269
             'id'   => 'bank_transfer_ac_name',
270
-            'name' => __( 'Account Name', 'invoicing' ),
270
+            'name' => __('Account Name', 'invoicing'),
271 271
 		);
272 272
 		
273 273
 		$admin_settings['bank_transfer_ac_no'] = array(
274 274
             'type' => 'text',
275 275
             'id'   => 'bank_transfer_ac_no',
276
-            'name' => __( 'Account Number', 'invoicing' ),
276
+            'name' => __('Account Number', 'invoicing'),
277 277
 		);
278 278
 		
279 279
 		$admin_settings['bank_transfer_bank_name'] = array(
280 280
             'type' => 'text',
281 281
             'id'   => 'bank_transfer_bank_name',
282
-            'name' => __( 'Bank Name', 'invoicing' ),
282
+            'name' => __('Bank Name', 'invoicing'),
283 283
 		);
284 284
 
285 285
 		$admin_settings['bank_transfer_ifsc'] = array(
286 286
             'type' => 'text',
287 287
             'id'   => 'bank_transfer_ifsc',
288
-            'name' => __( 'IFSC Code', 'invoicing' ),
288
+            'name' => __('IFSC Code', 'invoicing'),
289 289
 		);
290 290
 
291 291
 		$admin_settings['bank_transfer_iban'] = array(
292 292
             'type' => 'text',
293 293
             'id'   => 'bank_transfer_iban',
294
-            'name' => __( 'IBAN', 'invoicing' ),
294
+            'name' => __('IBAN', 'invoicing'),
295 295
 		);
296 296
 
297 297
 		$admin_settings['bank_transfer_bic'] = array(
298 298
             'type' => 'text',
299 299
             'id'   => 'bank_transfer_bic',
300
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
300
+            'name' => __('BIC/Swift Code', 'invoicing'),
301 301
 		);
302 302
 		
303 303
 		$admin_settings['bank_transfer_sort_code'] = array(
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 
309 309
 		$admin_settings['bank_transfer_info'] = array(
310 310
             'id'   => 'bank_transfer_info',
311
-            'name' => __( 'Instructions', 'invoicing' ),
312
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
311
+            'name' => __('Instructions', 'invoicing'),
312
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
313 313
             'type' => 'textarea',
314
-            'std'  => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ),
314
+            'std'  => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'),
315 315
             'cols' => 50,
316 316
             'rows' => 5
317 317
         );
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
 	 * @param GetPaid_Form_Item[] $items
327 327
 	 * @return WPInv_Invoice
328 328
 	 */
329
-	public function process_addons( $invoice, $items ) {
329
+	public function process_addons($invoice, $items) {
330 330
 
331
-        foreach ( $items as $item ) {
332
-            $invoice->add_item( $item );
331
+        foreach ($items as $item) {
332
+            $invoice->add_item($item);
333 333
         }
334 334
 
335 335
         $invoice->recalculate_total();
Please login to merge, or discard this patch.
templates/invoice/invoice-meta.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,50 +7,50 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$class = ! is_singular( 'page' ) ? 'px-1' : '';
12
+$class = !is_singular('page') ? 'px-1' : '';
13 13
 ?>
14 14
 
15
-        <?php do_action( 'getpaid_before_invoice_meta', $invoice ); ?>
15
+        <?php do_action('getpaid_before_invoice_meta', $invoice); ?>
16 16
         <div class="getpaid-invoice-meta-data">
17 17
 
18
-            <?php do_action( 'getpaid_before_invoice_meta_table', $invoice ); ?>
18
+            <?php do_action('getpaid_before_invoice_meta_table', $invoice); ?>
19 19
             <table class="table table-bordered">
20 20
                 <tbody>
21 21
 
22
-                    <?php do_action( "getpaid_before_invoice_meta_rows", $invoice ); ?>
23
-                    <?php foreach ( $meta as $key => $data ) : ?>
22
+                    <?php do_action("getpaid_before_invoice_meta_rows", $invoice); ?>
23
+                    <?php foreach ($meta as $key => $data) : ?>
24 24
 
25
-                        <?php if ( ! empty( $data['value'] ) ) : ?>
25
+                        <?php if (!empty($data['value'])) : ?>
26 26
 
27
-                            <?php do_action( "getpaid_before_invoice_meta_$key", $invoice, $data ); ?>
27
+                            <?php do_action("getpaid_before_invoice_meta_$key", $invoice, $data); ?>
28 28
 
29
-                            <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>">
29
+                            <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>">
30 30
 
31 31
                                 <th class="<?php echo $class; ?> font-weight-bold">
32
-                                    <?php echo sanitize_text_field( $data['label'] ); ?>
32
+                                    <?php echo sanitize_text_field($data['label']); ?>
33 33
                                 </th>
34 34
 
35 35
                                 <td class="<?php echo $class; ?> <?php echo $key == 'invoice_total' ? 'font-weight-bold' : 'font-weight-normal'; ?> text-break w-75">
36
-                                    <span class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>-value"><?php echo wp_kses_post( $data['value'] ); ?></span>
36
+                                    <span class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>-value"><?php echo wp_kses_post($data['value']); ?></span>
37 37
                                 </td>
38 38
 
39 39
                             </tr>
40 40
 
41
-                            <?php do_action( "getpaid_after_invoice_meta_$key", $invoice, $data ); ?>
41
+                            <?php do_action("getpaid_after_invoice_meta_$key", $invoice, $data); ?>
42 42
 
43 43
                         <?php endif; ?>
44 44
                     
45 45
                     <?php endforeach; ?>
46
-                    <?php do_action( "getpaid_after_invoice_meta_rows", $invoice ); ?>
46
+                    <?php do_action("getpaid_after_invoice_meta_rows", $invoice); ?>
47 47
 
48 48
                 </tbody>
49 49
             </table>
50
-            <?php do_action( 'getpaid_after_invoice_meta_table', $invoice ); ?>
50
+            <?php do_action('getpaid_after_invoice_meta_table', $invoice); ?>
51 51
 
52 52
 
53 53
         </div>
54
-        <?php do_action( 'getpaid_after_invoice_meta', $invoice ); ?>
54
+        <?php do_action('getpaid_after_invoice_meta', $invoice); ?>
55 55
 
56 56
 <?php
Please login to merge, or discard this patch.
templates/frontend-head.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
Please login to merge, or discard this patch.
templates/frontend-footer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  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 12
 ?>
13 13
 
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 		<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
17 17
 			<div class="modal-content">
18 18
 				<div class="modal-body">
19
-					<button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="<?php esc_attr__( 'Close', 'invoicing' ); ?>">
19
+					<button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="<?php esc_attr__('Close', 'invoicing'); ?>">
20 20
 						<i class="fa fa-times" aria-hidden="true"></i>
21 21
 					</button>
22 22
 					<div class="modal-body-wrapper"></div>
Please login to merge, or discard this patch.
templates/invoice/company-address.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@  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 12
 // Prepare the company name.
13
-$company_name = wpinv_get_option( 'vat_company_name' );
13
+$company_name = wpinv_get_option('vat_company_name');
14 14
 
15
-if ( empty( $company_name ) ) {
15
+if (empty($company_name)) {
16 16
     $company_name = wpinv_get_business_name();
17 17
 }
18 18
 
19 19
 // Prepare the VAT number.
20
-$vat_number = wpinv_get_option( 'vat_number' );
20
+$vat_number = wpinv_get_option('vat_number');
21 21
 
22 22
 ?>
23 23
     <div class="getpaid-company-address form-group">
@@ -25,36 +25,36 @@  discard block
 block discarded – undo
25 25
         <div class="row">
26 26
 
27 27
             <div class="invoice-company-address-label col-2">
28
-                <strong><?php _e( 'From:', 'invoicing' ) ?></strong>
28
+                <strong><?php _e('From:', 'invoicing') ?></strong>
29 29
             </div>
30 30
 
31 31
             <div class="invoice-company-address-value col-10">
32 32
 
33
-                <?php do_action( 'getpaid_company_address_top' ); ?>
33
+                <?php do_action('getpaid_company_address_top'); ?>
34 34
 
35 35
                 <div class="name">
36
-                    <a target="_blank" class="text-dark" href="<?php echo esc_url( wpinv_get_business_website() ); ?>">
37
-                        <?php echo esc_html( $company_name ); ?>
36
+                    <a target="_blank" class="text-dark" href="<?php echo esc_url(wpinv_get_business_website()); ?>">
37
+                        <?php echo esc_html($company_name); ?>
38 38
                     </a>
39 39
                 </div>
40 40
 
41
-                <?php if ( $address = wpinv_get_business_address() ) { ?>
42
-                    <?php echo $address;?>
41
+                <?php if ($address = wpinv_get_business_address()) { ?>
42
+                    <?php echo $address; ?>
43 43
                 <?php } ?>
44 44
 
45
-                <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
45
+                <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
46 46
                     <div class="email_from">
47
-                        <?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?>
47
+                        <?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?>
48 48
                     </div>
49 49
                 <?php } ?>
50 50
 
51
-                <?php if ( ! empty( $vat_number ) ) { ?>
51
+                <?php if (!empty($vat_number)) { ?>
52 52
                     <div class="email_from">
53
-                        <?php echo wp_sprintf( __( 'VAT Number: %s', 'invoicing' ), sanitize_text_field( $vat_number ) );?>
53
+                        <?php echo wp_sprintf(__('VAT Number: %s', 'invoicing'), sanitize_text_field($vat_number)); ?>
54 54
                     </div>
55 55
                 <?php } ?>
56 56
 
57
-                <?php do_action( 'getpaid_company_address_bottom' ); ?>
57
+                <?php do_action('getpaid_company_address_bottom'); ?>
58 58
 
59 59
             </div>
60 60
 
Please login to merge, or discard this patch.
templates/invoice/billing-address.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  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
-$invoice     = new WPInv_Invoice( $invoice );
13
-$address_row = wpinv_get_invoice_address_markup( $invoice->get_user_info() );
12
+$invoice     = new WPInv_Invoice($invoice);
13
+$address_row = wpinv_get_invoice_address_markup($invoice->get_user_info());
14 14
 $phone       = $invoice->get_phone();
15 15
 $email       = $invoice->get_email();
16 16
 $vat_number  = $invoice->get_vat_number();
@@ -21,41 +21,41 @@  discard block
 block discarded – undo
21 21
 
22 22
 
23 23
             <div class="invoice-billing-address-label col-2">
24
-                <strong><?php _e( 'To:', 'invoicing' ) ?></strong>
24
+                <strong><?php _e('To:', 'invoicing') ?></strong>
25 25
             </div>
26 26
 
27 27
 
28 28
             <div class="invoice-billing-address-value col-10">
29 29
 
30
-                <?php do_action( 'getpaid_billing_address_top' ); ?>
30
+                <?php do_action('getpaid_billing_address_top'); ?>
31 31
 
32
-                <?php if ( ! empty( $address_row ) ) : ?>
32
+                <?php if (!empty($address_row)) : ?>
33 33
                     <div class="billing-address">
34 34
                         <?php echo $address_row; ?>
35 35
                     </div>
36 36
                 <?php endif; ?>
37 37
 
38 38
 
39
-                <?php if ( ! empty( $phone ) ) : ?>
39
+                <?php if (!empty($phone)) : ?>
40 40
                     <div class="billing-phone">
41
-                        <?php echo wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ); ?>
41
+                        <?php echo wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)); ?>
42 42
                     </div>
43 43
                 <?php endif; ?>
44 44
 
45 45
 
46
-                <?php if ( ! empty( $email ) ) : ?>
46
+                <?php if (!empty($email)) : ?>
47 47
                     <div class="billing-email">
48
-                        <?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), sanitize_email( $email ) ); ?>
48
+                        <?php echo wp_sprintf(__('Email: %s', 'invoicing'), sanitize_email($email)); ?>
49 49
                     </div>
50 50
                 <?php endif; ?>
51 51
 
52
-                <?php if ( ! empty( $vat_number ) ) : ?>
52
+                <?php if (!empty($vat_number)) : ?>
53 53
                     <div class="vat-number">
54
-                        <?php echo wp_sprintf( __( 'Vat Number: %s', 'invoicing' ), sanitize_text_field( $vat_number ) ); ?>
54
+                        <?php echo wp_sprintf(__('Vat Number: %s', 'invoicing'), sanitize_text_field($vat_number)); ?>
55 55
                     </div>
56 56
                 <?php endif; ?>
57 57
 
58
-                <?php do_action( 'getpaid_billing_address_bottom' ); ?>
58
+                <?php do_action('getpaid_billing_address_bottom'); ?>
59 59
 
60 60
             </div>
61 61
 
Please login to merge, or discard this patch.
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='$minimum'";
82
-							}
81
+                                $data_minimum     = "data-minimum-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='$minimum'";
81
+								$data_minimum = "data-minimum-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 $price; ?>" placeholder="<?php echo esc_attr( $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 $price; ?>" placeholder="<?php echo esc_attr($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.