Passed
Pull Request — master (#462)
by Viktor
04:15
created
includes/reports/class-getpaid-reports-export.php 2 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -12,46 +12,46 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports_Export {
14 14
 
15
-	/**
16
-	 * Displays the reports tab.
17
-	 *
18
-	 */
19
-	public function display() {
20
-
21
-		echo "<div class='row mt-4' style='max-width: 920px;' >";
22
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
-			$this->display_post_type_export( $post_type );
24
-		}
25
-		echo "</div>";
26
-
27
-	}
28
-
29
-	/**
30
-	 * Retrieves the download url.
31
-	 *
32
-	 */
33
-	public function get_download_url( $post_type ) {
34
-
35
-		return wp_nonce_url(
36
-			add_query_arg(
37
-				array(
38
-					'getpaid-admin-action' => 'export_invoices',
39
-					'post_type'            => urlencode( $post_type ),
40
-				)
41
-			),
42
-			'getpaid-nonce',
43
-			'getpaid-nonce'
44
-		);
45
-
46
-	}
47
-
48
-	/**
49
-	 * Displays a single post type export card.
50
-	 *
51
-	 */
52
-	public function display_post_type_export( $post_type ) {
53
-
54
-		?>
15
+    /**
16
+     * Displays the reports tab.
17
+     *
18
+     */
19
+    public function display() {
20
+
21
+        echo "<div class='row mt-4' style='max-width: 920px;' >";
22
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
+            $this->display_post_type_export( $post_type );
24
+        }
25
+        echo "</div>";
26
+
27
+    }
28
+
29
+    /**
30
+     * Retrieves the download url.
31
+     *
32
+     */
33
+    public function get_download_url( $post_type ) {
34
+
35
+        return wp_nonce_url(
36
+            add_query_arg(
37
+                array(
38
+                    'getpaid-admin-action' => 'export_invoices',
39
+                    'post_type'            => urlencode( $post_type ),
40
+                )
41
+            ),
42
+            'getpaid-nonce',
43
+            'getpaid-nonce'
44
+        );
45
+
46
+    }
47
+
48
+    /**
49
+     * Displays a single post type export card.
50
+     *
51
+     */
52
+    public function display_post_type_export( $post_type ) {
53
+
54
+        ?>
55 55
 
56 56
 		<div class="col-12 col-md-6">
57 57
 			<div class="card m-0 p-0" style="max-width:100%">
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 				<div class="card-header">
60 60
 					<strong>
61 61
 						<?php
62
-							printf(
63
-								__( 'Export %s', 'invoicing' ),
64
-								sanitize_text_field( getpaid_get_post_type_label( $post_type ) )
65
-							);
66
-						?>
62
+                            printf(
63
+                                __( 'Export %s', 'invoicing' ),
64
+                                sanitize_text_field( getpaid_get_post_type_label( $post_type ) )
65
+                            );
66
+                        ?>
67 67
 					</strong>
68 68
 				</div>
69 69
 
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
 					<form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>">
73 73
 
74 74
 						<?php
75
-							$this->display_markup( $this->generate_from_date( $post_type ) );
76
-							$this->display_markup( $this->generate_to_date( $post_type ) );
77
-							$this->display_markup( $this->generate_post_status_select( $post_type ) );
78
-							$this->display_markup( $this->generate_file_type_select( $post_type ) );
79
-							submit_button( __( 'Download', 'invoicing' ) );
80
-						?>
75
+                            $this->display_markup( $this->generate_from_date( $post_type ) );
76
+                            $this->display_markup( $this->generate_to_date( $post_type ) );
77
+                            $this->display_markup( $this->generate_post_status_select( $post_type ) );
78
+                            $this->display_markup( $this->generate_file_type_select( $post_type ) );
79
+                            submit_button( __( 'Download', 'invoicing' ) );
80
+                        ?>
81 81
 
82 82
 					</form>
83 83
 
@@ -88,107 +88,107 @@  discard block
 block discarded – undo
88 88
 
89 89
 		<?php
90 90
 
91
-	}
92
-
93
-	/**
94
-	 * Generates the from date input field.
95
-	 *
96
-	 */
97
-	public function generate_from_date( $post_type ) {
98
-
99
-		return aui()->input(
100
-			array(
101
-				'name'       => 'from_date',
102
-				'id'         => esc_attr( "$post_type-from_date" ),
103
-				'placeholder'=> 'yy-mm-dd',
104
-				'label'      => __( 'From Date', 'invoicing' ),
105
-				'label_type' => 'vertical',
106
-				'label_class' => 'd-block',
107
-				'type'       => 'datepicker',
108
-			)
109
-		);
110
-
111
-	}
112
-
113
-	/**
114
-	 * Generates the to date input field.
115
-	 *
116
-	 */
117
-	public function generate_to_date( $post_type ) {
118
-
119
-		return aui()->input(
120
-			array(
121
-				'name'       => 'to_date',
122
-				'id'         => esc_attr( "$post_type-to_date" ),
123
-				'placeholder'=> 'yy-mm-dd',
124
-				'label'      => __( 'To Date', 'invoicing' ),
125
-				'label_type' => 'vertical',
126
-				'label_class' => 'd-block',
127
-				'type'       => 'datepicker',
128
-			)
129
-		);
130
-
131
-	}
132
-
133
-	/**
134
-	 * Generates the to post status select field.
135
-	 *
136
-	 */
137
-	public function generate_post_status_select( $post_type ) {
138
-
139
-		return aui()->select(
140
-			array(
141
-				'name'        => 'status',
142
-				'id'          => esc_attr( "$post_type-status" ),
143
-				'placeholder' => __( 'All Statuses', 'invoicing' ),
144
-				'label'       => __( 'Status', 'invoicing' ),
145
-				'label_type'  => 'vertical',
146
-				'label_class' => 'd-block',
147
-				'options'     => wpinv_get_invoice_statuses( true, false, $post_type ),
148
-			)
149
-		);
150
-
151
-	}
152
-
153
-	/**
154
-	 * Generates the to file type select field.
155
-	 *
156
-	 */
157
-	public function generate_file_type_select( $post_type ) {
158
-
159
-		return aui()->select(
160
-			array(
161
-				'name'        => 'file_type',
162
-				'id'          => esc_attr( "$post_type-file_type" ),
163
-				'placeholder' => __( 'Select File Type', 'invoicing' ),
164
-				'label'       => __( 'Export File', 'invoicing' ),
165
-				'label_type'  => 'vertical',
166
-				'label_class' => 'd-block',
167
-				'options'     => array(
168
-					'csv'  => __( 'CSV', 'invoicing' ),
169
-					'xml'  => __( 'XML', 'invoicing' ),
170
-					'json' => __( 'JSON', 'invoicing' ),
171
-				),
172
-			)
173
-		);
174
-
175
-	}
176
-
177
-	/**
178
-	 * Displays a field's markup.
179
-	 *
180
-	 */
181
-	public function display_markup( $markup ) {
182
-
183
-		echo str_replace(
184
-			array(
185
-				'form-control',
186
-				'custom-select'
187
-			),
188
-			'regular-text',
189
-			$markup
190
-		);
191
-
192
-	}
91
+    }
92
+
93
+    /**
94
+     * Generates the from date input field.
95
+     *
96
+     */
97
+    public function generate_from_date( $post_type ) {
98
+
99
+        return aui()->input(
100
+            array(
101
+                'name'       => 'from_date',
102
+                'id'         => esc_attr( "$post_type-from_date" ),
103
+                'placeholder'=> 'yy-mm-dd',
104
+                'label'      => __( 'From Date', 'invoicing' ),
105
+                'label_type' => 'vertical',
106
+                'label_class' => 'd-block',
107
+                'type'       => 'datepicker',
108
+            )
109
+        );
110
+
111
+    }
112
+
113
+    /**
114
+     * Generates the to date input field.
115
+     *
116
+     */
117
+    public function generate_to_date( $post_type ) {
118
+
119
+        return aui()->input(
120
+            array(
121
+                'name'       => 'to_date',
122
+                'id'         => esc_attr( "$post_type-to_date" ),
123
+                'placeholder'=> 'yy-mm-dd',
124
+                'label'      => __( 'To Date', 'invoicing' ),
125
+                'label_type' => 'vertical',
126
+                'label_class' => 'd-block',
127
+                'type'       => 'datepicker',
128
+            )
129
+        );
130
+
131
+    }
132
+
133
+    /**
134
+     * Generates the to post status select field.
135
+     *
136
+     */
137
+    public function generate_post_status_select( $post_type ) {
138
+
139
+        return aui()->select(
140
+            array(
141
+                'name'        => 'status',
142
+                'id'          => esc_attr( "$post_type-status" ),
143
+                'placeholder' => __( 'All Statuses', 'invoicing' ),
144
+                'label'       => __( 'Status', 'invoicing' ),
145
+                'label_type'  => 'vertical',
146
+                'label_class' => 'd-block',
147
+                'options'     => wpinv_get_invoice_statuses( true, false, $post_type ),
148
+            )
149
+        );
150
+
151
+    }
152
+
153
+    /**
154
+     * Generates the to file type select field.
155
+     *
156
+     */
157
+    public function generate_file_type_select( $post_type ) {
158
+
159
+        return aui()->select(
160
+            array(
161
+                'name'        => 'file_type',
162
+                'id'          => esc_attr( "$post_type-file_type" ),
163
+                'placeholder' => __( 'Select File Type', 'invoicing' ),
164
+                'label'       => __( 'Export File', 'invoicing' ),
165
+                'label_type'  => 'vertical',
166
+                'label_class' => 'd-block',
167
+                'options'     => array(
168
+                    'csv'  => __( 'CSV', 'invoicing' ),
169
+                    'xml'  => __( 'XML', 'invoicing' ),
170
+                    'json' => __( 'JSON', 'invoicing' ),
171
+                ),
172
+            )
173
+        );
174
+
175
+    }
176
+
177
+    /**
178
+     * Displays a field's markup.
179
+     *
180
+     */
181
+    public function display_markup( $markup ) {
182
+
183
+        echo str_replace(
184
+            array(
185
+                'form-control',
186
+                'custom-select'
187
+            ),
188
+            'regular-text',
189
+            $markup
190
+        );
191
+
192
+    }
193 193
 
194 194
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports_Export Class.
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 	public function display() {
20 20
 
21 21
 		echo "<div class='row mt-4' style='max-width: 920px;' >";
22
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
-			$this->display_post_type_export( $post_type );
22
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
23
+			$this->display_post_type_export($post_type);
24 24
 		}
25 25
 		echo "</div>";
26 26
 
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 	 * Retrieves the download url.
31 31
 	 *
32 32
 	 */
33
-	public function get_download_url( $post_type ) {
33
+	public function get_download_url($post_type) {
34 34
 
35 35
 		return wp_nonce_url(
36 36
 			add_query_arg(
37 37
 				array(
38 38
 					'getpaid-admin-action' => 'export_invoices',
39
-					'post_type'            => urlencode( $post_type ),
39
+					'post_type'            => urlencode($post_type),
40 40
 				)
41 41
 			),
42 42
 			'getpaid-nonce',
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * Displays a single post type export card.
50 50
 	 *
51 51
 	 */
52
-	public function display_post_type_export( $post_type ) {
52
+	public function display_post_type_export($post_type) {
53 53
 
54 54
 		?>
55 55
 
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 					<strong>
61 61
 						<?php
62 62
 							printf(
63
-								__( 'Export %s', 'invoicing' ),
64
-								sanitize_text_field( getpaid_get_post_type_label( $post_type ) )
63
+								__('Export %s', 'invoicing'),
64
+								sanitize_text_field(getpaid_get_post_type_label($post_type))
65 65
 							);
66 66
 						?>
67 67
 					</strong>
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 
70 70
 				<div class="card-body">
71 71
 
72
-					<form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>">
72
+					<form method="post" action="<?php echo esc_url($this->get_download_url($post_type)); ?>">
73 73
 
74 74
 						<?php
75
-							$this->display_markup( $this->generate_from_date( $post_type ) );
76
-							$this->display_markup( $this->generate_to_date( $post_type ) );
77
-							$this->display_markup( $this->generate_post_status_select( $post_type ) );
78
-							$this->display_markup( $this->generate_file_type_select( $post_type ) );
79
-							submit_button( __( 'Download', 'invoicing' ) );
75
+							$this->display_markup($this->generate_from_date($post_type));
76
+							$this->display_markup($this->generate_to_date($post_type));
77
+							$this->display_markup($this->generate_post_status_select($post_type));
78
+							$this->display_markup($this->generate_file_type_select($post_type));
79
+							submit_button(__('Download', 'invoicing'));
80 80
 						?>
81 81
 
82 82
 					</form>
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
 	 * Generates the from date input field.
95 95
 	 *
96 96
 	 */
97
-	public function generate_from_date( $post_type ) {
97
+	public function generate_from_date($post_type) {
98 98
 
99 99
 		return aui()->input(
100 100
 			array(
101 101
 				'name'       => 'from_date',
102
-				'id'         => esc_attr( "$post_type-from_date" ),
102
+				'id'         => esc_attr("$post_type-from_date"),
103 103
 				'placeholder'=> 'yy-mm-dd',
104
-				'label'      => __( 'From Date', 'invoicing' ),
104
+				'label'      => __('From Date', 'invoicing'),
105 105
 				'label_type' => 'vertical',
106 106
 				'label_class' => 'd-block',
107 107
 				'type'       => 'datepicker',
@@ -114,14 +114,14 @@  discard block
 block discarded – undo
114 114
 	 * Generates the to date input field.
115 115
 	 *
116 116
 	 */
117
-	public function generate_to_date( $post_type ) {
117
+	public function generate_to_date($post_type) {
118 118
 
119 119
 		return aui()->input(
120 120
 			array(
121 121
 				'name'       => 'to_date',
122
-				'id'         => esc_attr( "$post_type-to_date" ),
122
+				'id'         => esc_attr("$post_type-to_date"),
123 123
 				'placeholder'=> 'yy-mm-dd',
124
-				'label'      => __( 'To Date', 'invoicing' ),
124
+				'label'      => __('To Date', 'invoicing'),
125 125
 				'label_type' => 'vertical',
126 126
 				'label_class' => 'd-block',
127 127
 				'type'       => 'datepicker',
@@ -134,17 +134,17 @@  discard block
 block discarded – undo
134 134
 	 * Generates the to post status select field.
135 135
 	 *
136 136
 	 */
137
-	public function generate_post_status_select( $post_type ) {
137
+	public function generate_post_status_select($post_type) {
138 138
 
139 139
 		return aui()->select(
140 140
 			array(
141 141
 				'name'        => 'status',
142
-				'id'          => esc_attr( "$post_type-status" ),
143
-				'placeholder' => __( 'All Statuses', 'invoicing' ),
144
-				'label'       => __( 'Status', 'invoicing' ),
142
+				'id'          => esc_attr("$post_type-status"),
143
+				'placeholder' => __('All Statuses', 'invoicing'),
144
+				'label'       => __('Status', 'invoicing'),
145 145
 				'label_type'  => 'vertical',
146 146
 				'label_class' => 'd-block',
147
-				'options'     => wpinv_get_invoice_statuses( true, false, $post_type ),
147
+				'options'     => wpinv_get_invoice_statuses(true, false, $post_type),
148 148
 			)
149 149
 		);
150 150
 
@@ -154,20 +154,20 @@  discard block
 block discarded – undo
154 154
 	 * Generates the to file type select field.
155 155
 	 *
156 156
 	 */
157
-	public function generate_file_type_select( $post_type ) {
157
+	public function generate_file_type_select($post_type) {
158 158
 
159 159
 		return aui()->select(
160 160
 			array(
161 161
 				'name'        => 'file_type',
162
-				'id'          => esc_attr( "$post_type-file_type" ),
163
-				'placeholder' => __( 'Select File Type', 'invoicing' ),
164
-				'label'       => __( 'Export File', 'invoicing' ),
162
+				'id'          => esc_attr("$post_type-file_type"),
163
+				'placeholder' => __('Select File Type', 'invoicing'),
164
+				'label'       => __('Export File', 'invoicing'),
165 165
 				'label_type'  => 'vertical',
166 166
 				'label_class' => 'd-block',
167 167
 				'options'     => array(
168
-					'csv'  => __( 'CSV', 'invoicing' ),
169
-					'xml'  => __( 'XML', 'invoicing' ),
170
-					'json' => __( 'JSON', 'invoicing' ),
168
+					'csv'  => __('CSV', 'invoicing'),
169
+					'xml'  => __('XML', 'invoicing'),
170
+					'json' => __('JSON', 'invoicing'),
171 171
 				),
172 172
 			)
173 173
 		);
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * Displays a field's markup.
179 179
 	 *
180 180
 	 */
181
-	public function display_markup( $markup ) {
181
+	public function display_markup($markup) {
182 182
 
183 183
 		echo str_replace(
184 184
 			array(
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 *
18
-	 */
19
-	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
-
26
-	}
27
-
28
-	/**
29
-	 * Registers the reports page.
30
-	 *
31
-	 */
32
-	public function register_reports_page() {
33
-
34
-		add_submenu_page(
15
+    /**
16
+     * Class constructor.
17
+     *
18
+     */
19
+    public function __construct() {
20
+        add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
+        add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
+        add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
+        add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
+        add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
+
26
+    }
27
+
28
+    /**
29
+     * Registers the reports page.
30
+     *
31
+     */
32
+    public function register_reports_page() {
33
+
34
+        add_submenu_page(
35 35
             'wpinv',
36 36
             __( 'Reports', 'invoicing' ),
37 37
             __( 'Reports', 'invoicing' ),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40 40
             array( $this, 'display_reports_page' )
41
-		);
41
+        );
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Displays the reports page.
47
-	 *
48
-	 */
49
-	public function display_reports_page() {
45
+    /**
46
+     * Displays the reports page.
47
+     *
48
+     */
49
+    public function display_reports_page() {
50 50
 
51
-		// Prepare variables.
52
-		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
51
+        // Prepare variables.
52
+        $tabs        = $this->get_tabs();
53
+        $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
+        $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
55 55
 
56
-		// Display the current tab.
57
-		?>
56
+        // Display the current tab.
57
+        ?>
58 58
 
59 59
         <div class="wrap">
60 60
 
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach( $tabs as $key => $label ) {
66
+                    foreach( $tabs as $key => $label ) {
67 67
 
68
-						$key   = sanitize_text_field( $key );
69
-						$label = sanitize_text_field( $label );
70
-						$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
-						$url   = esc_url(
72
-							add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73
-						);
68
+                        $key   = sanitize_text_field( $key );
69
+                        $label = sanitize_text_field( $label );
70
+                        $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
+                        $url   = esc_url(
72
+                            add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73
+                        );
74 74
 
75
-						echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
75
+                        echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
76 76
 
77
-					}
78
-				?>
77
+                    }
78
+                ?>
79 79
 
80 80
 			</nav>
81 81
 
@@ -86,74 +86,74 @@  discard block
 block discarded – undo
86 86
         </div>
87 87
 		<?php
88 88
 
89
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true );
90
-			wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' );
89
+            wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true );
90
+            wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' );
91 91
 
92
-	}
92
+    }
93 93
 
94
-	/**
95
-	 * Retrieves reports page tabs.
96
-	 *
97
-	 * @return array
98
-	 */
99
-	public function get_tabs() {
94
+    /**
95
+     * Retrieves reports page tabs.
96
+     *
97
+     * @return array
98
+     */
99
+    public function get_tabs() {
100 100
 
101
-		$tabs = array(
102
-			'reports' => __( 'Reports', 'invoicing' ),
103
-			'export'  => __( 'Export', 'invoicing' ),
104
-		);
101
+        $tabs = array(
102
+            'reports' => __( 'Reports', 'invoicing' ),
103
+            'export'  => __( 'Export', 'invoicing' ),
104
+        );
105 105
 
106
-		return apply_filters( 'getpaid_report_tabs', $tabs );
107
-	}
106
+        return apply_filters( 'getpaid_report_tabs', $tabs );
107
+    }
108 108
 
109
-	/**
110
-	 * Displays the reports tab.
111
-	 *
112
-	 */
113
-	public function display_reports_tab() {
109
+    /**
110
+     * Displays the reports tab.
111
+     *
112
+     */
113
+    public function display_reports_tab() {
114 114
 
115
-		$reports = new GetPaid_Reports_Report();
116
-		$reports->display();
115
+        $reports = new GetPaid_Reports_Report();
116
+        $reports->display();
117 117
 
118
-	}
118
+    }
119 119
 
120
-	/**
121
-	 * Displays the exports tab.
122
-	 *
123
-	 */
124
-	public function display_exports_tab() {
120
+    /**
121
+     * Displays the exports tab.
122
+     *
123
+     */
124
+    public function display_exports_tab() {
125 125
 
126
-		$exports = new GetPaid_Reports_Export();
127
-		$exports->display();
126
+        $exports = new GetPaid_Reports_Export();
127
+        $exports->display();
128 128
 
129
-	}
129
+    }
130 130
 
131
-	/**
132
-	 * Donwnloads a graph.
133
-	 *
134
-	 * @param array $args
135
-	 */
136
-	public function download_graph( $args ) {
131
+    /**
132
+     * Donwnloads a graph.
133
+     *
134
+     * @param array $args
135
+     */
136
+    public function download_graph( $args ) {
137 137
 
138
-		if ( ! empty( $args['graph'] ) ) {
139
-			$downloader = new GetPaid_Graph_Downloader();
140
-			$downloader->download( $args['graph'] );
141
-		}
138
+        if ( ! empty( $args['graph'] ) ) {
139
+            $downloader = new GetPaid_Graph_Downloader();
140
+            $downloader->download( $args['graph'] );
141
+        }
142 142
 
143
-	}
143
+    }
144 144
 
145
-	/**
146
-	 * Exports invoices.
147
-	 *
148
-	 * @param array $args
149
-	 */
150
-	public function export_invoices( $args ) {
145
+    /**
146
+     * Exports invoices.
147
+     *
148
+     * @param array $args
149
+     */
150
+    public function export_invoices( $args ) {
151 151
 
152
-		if ( ! empty( $args['post_type'] ) ) {
153
-			$downloader = new GetPaid_Invoice_Exporter();
154
-			$downloader->export( $args['post_type'], $args );
155
-		}
152
+        if ( ! empty( $args['post_type'] ) ) {
153
+            $downloader = new GetPaid_Invoice_Exporter();
154
+            $downloader->export( $args['post_type'], $args );
155
+        }
156 156
 
157
-	}
157
+    }
158 158
 
159 159
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports Class.
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 */
19 19
 	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
20
+		add_action('admin_menu', array($this, 'register_reports_page'), 20);
21
+		add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab'));
22
+		add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab'));
23
+		add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph'));
24
+		add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices'));
25 25
 
26 26
 	}
27 27
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 		add_submenu_page(
35 35
             'wpinv',
36
-            __( 'Reports', 'invoicing' ),
37
-            __( 'Reports', 'invoicing' ),
36
+            __('Reports', 'invoicing'),
37
+            __('Reports', 'invoicing'),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40
-            array( $this, 'display_reports_page' )
40
+            array($this, 'display_reports_page')
41 41
 		);
42 42
 
43 43
 	}
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Prepare variables.
52 52
 		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
53
+		$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports';
54
+		$current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports';
55 55
 
56 56
 		// Display the current tab.
57 57
 		?>
58 58
 
59 59
         <div class="wrap">
60 60
 
61
-			<h1><?php echo sanitize_text_field( $tabs[ $current_tab ] ); ?></h1>
61
+			<h1><?php echo sanitize_text_field($tabs[$current_tab]); ?></h1>
62 62
 
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach( $tabs as $key => $label ) {
66
+					foreach ($tabs as $key => $label) {
67 67
 
68
-						$key   = sanitize_text_field( $key );
69
-						$label = sanitize_text_field( $label );
68
+						$key   = sanitize_text_field($key);
69
+						$label = sanitize_text_field($label);
70 70
 						$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71 71
 						$url   = esc_url(
72
-							add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
72
+							add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports'))
73 73
 						);
74 74
 
75 75
 						echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
@@ -79,15 +79,15 @@  discard block
 block discarded – undo
79 79
 
80 80
 			</nav>
81 81
 
82
-			<div class="bsui <?php echo esc_attr( $current_tab ); ?>">
83
-				<?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?>
82
+			<div class="bsui <?php echo esc_attr($current_tab); ?>">
83
+				<?php do_action("wpinv_reports_tab_{$current_tab}"); ?>
84 84
 			</div>
85 85
 
86 86
         </div>
87 87
 		<?php
88 88
 
89
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true );
90
-			wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' );
89
+			wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array('jquery'), '2.9.4', true);
90
+			wp_enqueue_style('chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4');
91 91
 
92 92
 	}
93 93
 
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 	public function get_tabs() {
100 100
 
101 101
 		$tabs = array(
102
-			'reports' => __( 'Reports', 'invoicing' ),
103
-			'export'  => __( 'Export', 'invoicing' ),
102
+			'reports' => __('Reports', 'invoicing'),
103
+			'export'  => __('Export', 'invoicing'),
104 104
 		);
105 105
 
106
-		return apply_filters( 'getpaid_report_tabs', $tabs );
106
+		return apply_filters('getpaid_report_tabs', $tabs);
107 107
 	}
108 108
 
109 109
 	/**
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param array $args
135 135
 	 */
136
-	public function download_graph( $args ) {
136
+	public function download_graph($args) {
137 137
 
138
-		if ( ! empty( $args['graph'] ) ) {
138
+		if (!empty($args['graph'])) {
139 139
 			$downloader = new GetPaid_Graph_Downloader();
140
-			$downloader->download( $args['graph'] );
140
+			$downloader->download($args['graph']);
141 141
 		}
142 142
 
143 143
 	}
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @param array $args
149 149
 	 */
150
-	public function export_invoices( $args ) {
150
+	public function export_invoices($args) {
151 151
 
152
-		if ( ! empty( $args['post_type'] ) ) {
152
+		if (!empty($args['post_type'])) {
153 153
 			$downloader = new GetPaid_Invoice_Exporter();
154
-			$downloader->export( $args['post_type'], $args );
154
+			$downloader->export($args['post_type'], $args);
155 155
 		}
156 156
 
157 157
 	}
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-report.php 2 patches
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -12,46 +12,46 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports_Report {
14 14
 
15
-	/**
16
-	 * @var array
17
-	 */
18
-	public $views;
15
+    /**
16
+     * @var array
17
+     */
18
+    public $views;
19 19
 
20
-	/**
21
-	 * Class constructor.
22
-	 *
23
-	 */
24
-	public function __construct() {
20
+    /**
21
+     * Class constructor.
22
+     *
23
+     */
24
+    public function __construct() {
25 25
 
26
-		$this->views        = array(
26
+        $this->views        = array(
27 27
 
28 28
             'items'     => array(
29
-				'label' => __( 'Items', 'invoicing' ),
30
-				'class' => 'GetPaid_Reports_Report_Items',
31
-			),
29
+                'label' => __( 'Items', 'invoicing' ),
30
+                'class' => 'GetPaid_Reports_Report_Items',
31
+            ),
32 32
 
33
-			'gateways'  => array(
34
-				'label' => __( 'Payment Methods', 'invoicing' ),
35
-				'class' => 'GetPaid_Reports_Report_Gateways',
36
-			),
33
+            'gateways'  => array(
34
+                'label' => __( 'Payment Methods', 'invoicing' ),
35
+                'class' => 'GetPaid_Reports_Report_Gateways',
36
+            ),
37 37
 
38
-			'discounts'  => array(
39
-				'label' => __( 'Discount Codes', 'invoicing' ),
40
-				'class' => 'GetPaid_Reports_Report_Discounts',
41
-			),
38
+            'discounts'  => array(
39
+                'label' => __( 'Discount Codes', 'invoicing' ),
40
+                'class' => 'GetPaid_Reports_Report_Discounts',
41
+            ),
42 42
 
43 43
         );
44 44
 
45
-		$this->views        = apply_filters( 'wpinv_report_views', $this->views );
45
+        $this->views        = apply_filters( 'wpinv_report_views', $this->views );
46 46
 
47
-	}
47
+    }
48 48
 
49
-	/**
50
-	 * Displays the reports tab.
51
-	 *
52
-	 */
53
-	public function display() {
54
-		?>
49
+    /**
50
+     * Displays the reports tab.
51
+     *
52
+     */
53
+    public function display() {
54
+        ?>
55 55
 
56 56
 		<div class="mt-4" style="max-width: 1200px;">
57 57
 
@@ -69,44 +69,44 @@  discard block
 block discarded – undo
69 69
 
70 70
 		<?php
71 71
 
72
-	}
73
-
74
-	/**
75
-	 * Displays the left side.
76
-	 *
77
-	 */
78
-	public function display_left() {
79
-		$earnings = new GetPaid_Reports_Report_Earnings();
80
-		$earnings->display();
81
-	}
82
-
83
-	/**
84
-	 * Retrieves the download url.
85
-	 *
86
-	 */
87
-	public function get_download_url( $graph, $file_type ) {
88
-
89
-		return wp_nonce_url(
90
-			add_query_arg(
91
-				array(
92
-					'getpaid-admin-action' => 'download_graph',
93
-					'file_type'            => urlencode( $file_type ),
94
-					'graph'                => urlencode( $graph ),
95
-				)
96
-			),
97
-			'getpaid-nonce',
98
-			'getpaid-nonce'
99
-		);
100
-
101
-	}
102
-
103
-	/**
104
-	 * Displays the right side.
105
-	 *
106
-	 */
107
-	public function display_right() {
108
-
109
-		?>
72
+    }
73
+
74
+    /**
75
+     * Displays the left side.
76
+     *
77
+     */
78
+    public function display_left() {
79
+        $earnings = new GetPaid_Reports_Report_Earnings();
80
+        $earnings->display();
81
+    }
82
+
83
+    /**
84
+     * Retrieves the download url.
85
+     *
86
+     */
87
+    public function get_download_url( $graph, $file_type ) {
88
+
89
+        return wp_nonce_url(
90
+            add_query_arg(
91
+                array(
92
+                    'getpaid-admin-action' => 'download_graph',
93
+                    'file_type'            => urlencode( $file_type ),
94
+                    'graph'                => urlencode( $graph ),
95
+                )
96
+            ),
97
+            'getpaid-nonce',
98
+            'getpaid-nonce'
99
+        );
100
+
101
+    }
102
+
103
+    /**
104
+     * Displays the right side.
105
+     *
106
+     */
107
+    public function display_right() {
108
+
109
+        ?>
110 110
 
111 111
 			<?php foreach ( $this->views as $key => $view ) : ?>
112 112
 				<div class="row mb-4">
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
 							</div>
136 136
 							<div class="card-body">
137 137
 								<?php
138
-									$class = $view['class'];
139
-									$class = new $class();
140
-									$class->display_stats();
141
-								?>
138
+                                    $class = $view['class'];
139
+                                    $class = new $class();
140
+                                    $class->display_stats();
141
+                                ?>
142 142
 							</div>
143 143
 						</div>
144 144
 					</div>
@@ -147,6 +147,6 @@  discard block
 block discarded – undo
147 147
 
148 148
 		<?php
149 149
 
150
-	}
150
+    }
151 151
 
152 152
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports_Report Class.
@@ -23,26 +23,26 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function __construct() {
25 25
 
26
-		$this->views        = array(
26
+		$this->views = array(
27 27
 
28 28
             'items'     => array(
29
-				'label' => __( 'Items', 'invoicing' ),
29
+				'label' => __('Items', 'invoicing'),
30 30
 				'class' => 'GetPaid_Reports_Report_Items',
31 31
 			),
32 32
 
33 33
 			'gateways'  => array(
34
-				'label' => __( 'Payment Methods', 'invoicing' ),
34
+				'label' => __('Payment Methods', 'invoicing'),
35 35
 				'class' => 'GetPaid_Reports_Report_Gateways',
36 36
 			),
37 37
 
38 38
 			'discounts'  => array(
39
-				'label' => __( 'Discount Codes', 'invoicing' ),
39
+				'label' => __('Discount Codes', 'invoicing'),
40 40
 				'class' => 'GetPaid_Reports_Report_Discounts',
41 41
 			),
42 42
 
43 43
         );
44 44
 
45
-		$this->views        = apply_filters( 'wpinv_report_views', $this->views );
45
+		$this->views = apply_filters('wpinv_report_views', $this->views);
46 46
 
47 47
 	}
48 48
 
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 	 * Retrieves the download url.
85 85
 	 *
86 86
 	 */
87
-	public function get_download_url( $graph, $file_type ) {
87
+	public function get_download_url($graph, $file_type) {
88 88
 
89 89
 		return wp_nonce_url(
90 90
 			add_query_arg(
91 91
 				array(
92 92
 					'getpaid-admin-action' => 'download_graph',
93
-					'file_type'            => urlencode( $file_type ),
94
-					'graph'                => urlencode( $graph ),
93
+					'file_type'            => urlencode($file_type),
94
+					'graph'                => urlencode($graph),
95 95
 				)
96 96
 			),
97 97
 			'getpaid-nonce',
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 
109 109
 		?>
110 110
 
111
-			<?php foreach ( $this->views as $key => $view ) : ?>
111
+			<?php foreach ($this->views as $key => $view) : ?>
112 112
 				<div class="row mb-4">
113 113
 					<div class="col-12">
114 114
 						<div class="card m-0 p-0" style="max-width:100%">
@@ -118,17 +118,17 @@  discard block
 block discarded – undo
118 118
 										<strong><?php echo $view['label']; ?></strong>
119 119
 									</div>
120 120
 									<div class="col-3">
121
-										<a title="<?php esc_attr_e( 'Download JSON', 'invoicing' ); ?>" href="<?php echo esc_url( $this->get_download_url( $key, 'json' ) ); ?>">
121
+										<a title="<?php esc_attr_e('Download JSON', 'invoicing'); ?>" href="<?php echo esc_url($this->get_download_url($key, 'json')); ?>">
122 122
 											<i class="fa fa-download text-dark" style="font-size: 16px" aria-hidden="true"></i>
123
-											<span class="screen-reader-text"><?php _e( 'Download JSON', 'invoicing' ); ?></span>
123
+											<span class="screen-reader-text"><?php _e('Download JSON', 'invoicing'); ?></span>
124 124
 										</a>
125
-										<a title="<?php esc_attr_e( 'Download CSV', 'invoicing' ); ?>" href="<?php echo esc_url( $this->get_download_url( $key, 'csv' ) ); ?>">
125
+										<a title="<?php esc_attr_e('Download CSV', 'invoicing'); ?>" href="<?php echo esc_url($this->get_download_url($key, 'csv')); ?>">
126 126
 											<i class="fa fa-file-csv text-dark" style="font-size: 16px" aria-hidden="true"></i>
127
-											<span class="screen-reader-text"><?php _e( 'Download CSV', 'invoicing' ); ?></span>
127
+											<span class="screen-reader-text"><?php _e('Download CSV', 'invoicing'); ?></span>
128 128
 										</a>
129
-										<a title="<?php esc_attr_e( 'Download XML', 'invoicing' ); ?>" href="<?php echo esc_url( $this->get_download_url( $key, 'xml' ) ); ?>">
129
+										<a title="<?php esc_attr_e('Download XML', 'invoicing'); ?>" href="<?php echo esc_url($this->get_download_url($key, 'xml')); ?>">
130 130
 											<i class="fa fa-file-code text-dark" style="font-size: 16px" aria-hidden="true"></i>
131
-											<span class="screen-reader-text"><?php _e( 'Download XML', 'invoicing' ); ?></span>
131
+											<span class="screen-reader-text"><?php _e('Download XML', 'invoicing'); ?></span>
132 132
 										</a>
133 133
 									</div>
134 134
 								</div>
Please login to merge, or discard this patch.
templates/payment-forms/elements/address-fields.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,48 +11,48 @@  discard block
 block discarded – undo
11 11
  * @var string $country The current user's country
12 12
  */
13 13
 
14
-defined( 'ABSPATH' ) || exit;
14
+defined('ABSPATH') || exit;
15 15
 
16 16
 
17
-$field_type = sanitize_key( $field_type );
17
+$field_type = sanitize_key($field_type);
18 18
 
19 19
 echo "<div class='row $field_type'>";
20 20
 
21
-foreach ( $fields as $address_field ) {
21
+foreach ($fields as $address_field) {
22 22
 
23 23
     // Skip if it is hidden.
24
-    if ( empty( $address_field['visible'] ) ) {
24
+    if (empty($address_field['visible'])) {
25 25
         continue;
26 26
     }
27 27
 
28
-    do_action( 'getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field );
28
+    do_action('getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field);
29 29
 
30 30
     // Prepare variables.
31 31
     $field_name  = $address_field['name'];
32 32
     $field_name  = "{$field_type}[$field_name]";
33
-    $wrap_class  = getpaid_get_form_element_grid_class( $address_field );
34
-    $wrap_class  = esc_attr( "$wrap_class getpaid-address-field-wrapper" );
35
-    $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
36
-    $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
37
-    $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_' . $address_field['name'], true ) : '';
38
-    $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
39
-
40
-    if ( ! empty( $address_field['required'] ) ) {
33
+    $wrap_class  = getpaid_get_form_element_grid_class($address_field);
34
+    $wrap_class  = esc_attr("$wrap_class getpaid-address-field-wrapper");
35
+    $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
36
+    $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
37
+    $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_' . $address_field['name'], true) : '';
38
+    $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
39
+
40
+    if (!empty($address_field['required'])) {
41 41
         $label .= "<span class='text-danger'> *</span>";
42 42
     }
43 43
 
44 44
     // Display the country.
45
-    if ( 'wpinv_country' == $address_field['name'] ) {
45
+    if ('wpinv_country' == $address_field['name']) {
46 46
 
47 47
         echo aui()->select(
48 48
             array(
49 49
                 'options'     => wpinv_get_country_list(),
50
-                'name'        => esc_attr( $field_name ),
51
-                'id'          => sanitize_html_class( $field_name ) . $uniqid,
52
-                'value'       => sanitize_text_field( $country ),
50
+                'name'        => esc_attr($field_name),
51
+                'id'          => sanitize_html_class($field_name) . $uniqid,
52
+                'value'       => sanitize_text_field($country),
53 53
                 'placeholder' => $placeholder,
54
-                'required'    => ! empty( $address_field['required'] ),
55
-                'label'       => wp_kses_post( $label ),
54
+                'required'    => !empty($address_field['required']),
55
+                'label'       => wp_kses_post($label),
56 56
                 'label_type'  => 'vertical',
57 57
                 'help_text'   => $description,
58 58
                 'class'       => 'getpaid-address-field wpinv_country',
@@ -64,39 +64,39 @@  discard block
 block discarded – undo
64 64
     }
65 65
 
66 66
     // Display the state.
67
-    else if ( 'wpinv_state' == $address_field['name'] ) {
67
+    else if ('wpinv_state' == $address_field['name']) {
68 68
 
69
-        if ( empty( $value ) ) {
69
+        if (empty($value)) {
70 70
             $value = wpinv_get_default_state();
71 71
         }
72 72
 
73
-        echo getpaid_get_states_select_markup (
73
+        echo getpaid_get_states_select_markup(
74 74
             $country,
75 75
             $value,
76 76
             $placeholder,
77 77
             $label,
78 78
             $description,
79
-            ! empty( $address_field['required'] ),
79
+            !empty($address_field['required']),
80 80
             $wrap_class,
81 81
             $field_name
82 82
         );
83 83
 
84 84
     } else {
85 85
 
86
-        $key = str_replace( 'wpinv_', '', $address_field['name'] );
87
-        $key = esc_attr( str_replace( '_', '-', $key ) );
86
+        $key = str_replace('wpinv_', '', $address_field['name']);
87
+        $key = esc_attr(str_replace('_', '-', $key));
88 88
         echo aui()->input(
89 89
             array(
90
-                'name'        => esc_attr( $field_name ),
91
-                'id'          => sanitize_html_class( $field_name ) . $uniqid,
92
-                'required'    => ! empty( $address_field['required'] ),
90
+                'name'        => esc_attr($field_name),
91
+                'id'          => sanitize_html_class($field_name) . $uniqid,
92
+                'required'    => !empty($address_field['required']),
93 93
                 'placeholder' => $placeholder,
94
-                'label'       => wp_kses_post( $label ),
94
+                'label'       => wp_kses_post($label),
95 95
                 'label_type'  => 'vertical',
96 96
                 'help_text'   => $description,
97 97
                 'type'        => 'text',
98
-                'value'       => sanitize_text_field( $value ),
99
-                'class'       => 'getpaid-address-field ' . esc_attr( $address_field['name'] ),
98
+                'value'       => sanitize_text_field($value),
99
+                'class'       => 'getpaid-address-field ' . esc_attr($address_field['name']),
100 100
                 'wrap_class'  => "$wrap_class getpaid-address-field-wrapper__$key",
101 101
                 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key,
102 102
             )
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
     }
106 106
 
107
-    do_action( 'getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field );
107
+    do_action('getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field);
108 108
 }
109 109
 
110 110
 echo "</div>";
Please login to merge, or discard this patch.
templates/payment-forms/elements/pay_button.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@  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
-$class = empty( $class ) ? 'btn-primary' : sanitize_html_class( $class );
13
-$label = empty( $label ) ? esc_attr__( 'Pay %price% »', 'invoicing' ) : esc_attr( $label );
14
-$free  = empty( $free ) ? esc_attr__( 'Continue »', 'invoicing' ) : esc_attr( $free );
12
+$class = empty($class) ? 'btn-primary' : sanitize_html_class($class);
13
+$label = empty($label) ? esc_attr__('Pay %price% »', 'invoicing') : esc_attr($label);
14
+$free  = empty($free) ? esc_attr__('Continue »', 'invoicing') : esc_attr($free);
15 15
 
16
-do_action( 'getpaid_before_payment_form_pay_button', $form );
16
+do_action('getpaid_before_payment_form_pay_button', $form);
17 17
 
18 18
 echo aui()->input(
19 19
     array(
20
-        'name'             => esc_attr( $id ),
21
-        'id'               => esc_attr( $id ) . uniqid( '_' ),
20
+        'name'             => esc_attr($id),
21
+        'id'               => esc_attr($id) . uniqid('_'),
22 22
         'value'            => $label,
23
-        'help_text'        => empty( $description ) ? '' : wp_kses_post( $description ),
23
+        'help_text'        => empty($description) ? '' : wp_kses_post($description),
24 24
         'type'             => 'submit',
25 25
         'class'            => 'getpaid-payment-form-submit btn btn-block submit-button ' . $class,
26 26
         'extra_attributes' => array(
@@ -30,4 +30,4 @@  discard block
 block discarded – undo
30 30
     )
31 31
 );
32 32
 
33
-do_action( 'getpaid_after_payment_form_pay_button', $form );
34 33
\ No newline at end of file
34
+do_action('getpaid_after_payment_form_pay_button', $form);
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-tax-functions.php 3 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -256,8 +256,9 @@
 block discarded – undo
256 256
 }
257 257
 
258 258
 function wpinv_cart_needs_tax_address_fields() {
259
-    if( !wpinv_is_cart_taxed() )
260
-        return false;
259
+    if( !wpinv_is_cart_taxed() ) {
260
+            return false;
261
+    }
261 262
 
262 263
     return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' );
263 264
 }
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
 function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) {
216 216
 
217 217
     $initial_tax   = $tax_amount;
218
-	$recurring_tax = 0;
218
+    $recurring_tax = 0;
219 219
 
220 220
     if ( $item->is_recurring() ) {
221
-		$recurring_tax = $recurring_tax_amount;
222
-	}
221
+        $recurring_tax = $recurring_tax_amount;
222
+    }
223 223
 
224
-	return array(
225
-		'name'          => sanitize_text_field( $tax_name ),
226
-		'initial_tax'   => $initial_tax,
227
-		'recurring_tax' => $recurring_tax,
224
+    return array(
225
+        'name'          => sanitize_text_field( $tax_name ),
226
+        'initial_tax'   => $initial_tax,
227
+        'recurring_tax' => $recurring_tax,
228 228
     );
229 229
 
230 230
 }
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
  */
329 329
 function wpinv_should_validate_vat_number() {
330 330
     $validate = wpinv_get_option( 'validate_vat_number' );
331
-	return ! empty( $validate );
331
+    return ! empty( $validate );
332 332
 }
333 333
 
334 334
 function wpinv_sales_tax_for_year( $year = null ) {
Please login to merge, or discard this patch.
Spacing   +118 added lines, -118 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
  * Returns an array of eu states.
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @return array
13 13
  */
14 14
 function getpaid_get_eu_states() {
15
-    return wpinv_get_data( 'eu-states' );
15
+    return wpinv_get_data('eu-states');
16 16
 }
17 17
 
18 18
 /**
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
  * 
21 21
  * @return bool
22 22
  */
23
-function getpaid_is_eu_state( $country ) {
24
-    return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_eu_states() ) ? true : false;
23
+function getpaid_is_eu_state($country) {
24
+    return !empty($country) && in_array(strtoupper($country), getpaid_get_eu_states()) ? true : false;
25 25
 }
26 26
 
27 27
 /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  * @return array
31 31
  */
32 32
 function getpaid_get_gst_states() {
33
-    return array( 'AU', 'NZ', 'CA', 'CN' );
33
+    return array('AU', 'NZ', 'CA', 'CN');
34 34
 }
35 35
 
36 36
 /**
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
  * 
39 39
  * @return bool
40 40
  */
41
-function getpaid_is_gst_country( $country ) {
42
-    return ! empty( $country ) && in_array( strtoupper( $country ), getpaid_get_gst_states() ) ? true : false;
41
+function getpaid_is_gst_country($country) {
42
+    return !empty($country) && in_array(strtoupper($country), getpaid_get_gst_states()) ? true : false;
43 43
 }
44 44
 
45 45
 /**
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
  */
50 50
 function wpinv_use_taxes() {
51 51
 
52
-    $ret = wpinv_get_option( 'enable_taxes', false );
53
-    return (bool) apply_filters( 'wpinv_use_taxes', ! empty( $ret ) );
52
+    $ret = wpinv_get_option('enable_taxes', false);
53
+    return (bool) apply_filters('wpinv_use_taxes', !empty($ret));
54 54
 
55 55
 }
56 56
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
  * @param WPInv_Invoice $invoice
61 61
  * @return bool
62 62
  */
63
-function wpinv_is_invoice_taxable( $invoice ) {
63
+function wpinv_is_invoice_taxable($invoice) {
64 64
     return $invoice->is_taxable();
65 65
 }
66 66
 
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
  * @param string $country
71 71
  * @return bool
72 72
  */
73
-function wpinv_is_country_taxable( $country ) {
74
-    $is_eu     = getpaid_is_eu_state( $country );
75
-    $is_exempt = $is_eu && $country == wpinv_is_base_country( $country ) && wpinv_same_country_exempt_vat();
73
+function wpinv_is_country_taxable($country) {
74
+    $is_eu     = getpaid_is_eu_state($country);
75
+    $is_exempt = $is_eu && $country == wpinv_is_base_country($country) && wpinv_same_country_exempt_vat();
76 76
 
77
-    return (bool) apply_filters( 'wpinv_is_country_taxable', ! $is_exempt, $country ); 
77
+    return (bool) apply_filters('wpinv_is_country_taxable', !$is_exempt, $country); 
78 78
 
79 79
 }
80 80
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
  * @param WPInv_Item|GetPaid_Form_Item $item
85 85
  * @return bool
86 86
  */
87
-function wpinv_is_item_taxable( $item ) {
87
+function wpinv_is_item_taxable($item) {
88 88
     return '_exempt' != $item->get_vat_rule();
89 89
 }
90 90
 
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
  * @return bool
95 95
  */
96 96
 function wpinv_use_store_address_as_tax_base() {
97
-    $use_base = wpinv_get_option( 'tax_base', 'billing' ) == 'base';
98
-    return (bool) apply_filters( 'wpinv_use_store_address_as_tax_base', $use_base );
97
+    $use_base = wpinv_get_option('tax_base', 'billing') == 'base';
98
+    return (bool) apply_filters('wpinv_use_store_address_as_tax_base', $use_base);
99 99
 }
100 100
 
101 101
 /**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
  * @return bool
105 105
  */
106 106
 function wpinv_prices_include_tax() {
107
-    $is_inclusive = wpinv_get_option( 'prices_include_tax', 'no' ) == 'yes';
108
-    return (bool) apply_filters( 'wpinv_prices_include_tax', $is_inclusive );
107
+    $is_inclusive = wpinv_get_option('prices_include_tax', 'no') == 'yes';
108
+    return (bool) apply_filters('wpinv_prices_include_tax', $is_inclusive);
109 109
 }
110 110
 
111 111
 /**
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
  * @return bool
115 115
  */
116 116
 function wpinv_round_tax_per_tax_rate() {
117
-    $subtotal_rounding = wpinv_get_option( 'tax_subtotal_rounding', 1 );
118
-    return (bool) apply_filters( 'wpinv_round_tax_per_tax_rate', empty( $subtotal_rounding ) );
117
+    $subtotal_rounding = wpinv_get_option('tax_subtotal_rounding', 1);
118
+    return (bool) apply_filters('wpinv_round_tax_per_tax_rate', empty($subtotal_rounding));
119 119
 }
120 120
 
121 121
 /**
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
  * @return bool
125 125
  */
126 126
 function wpinv_display_individual_tax_rates() {
127
-    $individual = wpinv_get_option( 'tax_display_totals', 'single' ) == 'individual';
128
-    return (bool) apply_filters( 'wpinv_display_individual_tax_rates', $individual );
127
+    $individual = wpinv_get_option('tax_display_totals', 'single') == 'individual';
128
+    return (bool) apply_filters('wpinv_display_individual_tax_rates', $individual);
129 129
 }
130 130
 
131 131
 /**
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
  * @return float
135 135
  */
136 136
 function wpinv_get_default_tax_rate() {
137
-    $rate = wpinv_get_option( 'tax_rate', false );
138
-    return (float) apply_filters( 'wpinv_get_default_tax_rate', floatval( $rate ) );
137
+    $rate = wpinv_get_option('tax_rate', false);
138
+    return (float) apply_filters('wpinv_get_default_tax_rate', floatval($rate));
139 139
 }
140 140
 
141 141
 /**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
  * @return bool
145 145
  */
146 146
 function wpinv_same_country_exempt_vat() {
147
-    return 'no' == wpinv_get_option( 'vat_same_country_rule' );
147
+    return 'no' == wpinv_get_option('vat_same_country_rule');
148 148
 }
149 149
 
150 150
 /**
@@ -164,28 +164,28 @@  discard block
 block discarded – undo
164 164
  * @param string $state
165 165
  * @return array
166 166
  */
167
-function getpaid_get_item_tax_rates( $item, $country = '', $state = '' ) {
167
+function getpaid_get_item_tax_rates($item, $country = '', $state = '') {
168 168
 
169 169
     // Abort if the item is not taxable.
170
-    if ( ! wpinv_is_item_taxable( $item ) ) {
170
+    if (!wpinv_is_item_taxable($item)) {
171 171
         return array();
172 172
     }
173 173
 
174 174
     // Maybe use the store address.
175
-    if ( wpinv_use_store_address_as_tax_base() ) {
175
+    if (wpinv_use_store_address_as_tax_base()) {
176 176
         $country = wpinv_get_default_country();
177 177
         $state   = wpinv_get_default_state();
178 178
     }
179 179
 
180 180
     // Retrieve tax rates.
181
-    $tax_rates = GetPaid_Tax::get_address_tax_rates( $country, $state );
181
+    $tax_rates = GetPaid_Tax::get_address_tax_rates($country, $state);
182 182
 
183 183
     // Fallback to the default tax rates if non were found.
184
-    if ( empty( $tax_rates ) ) {
184
+    if (empty($tax_rates)) {
185 185
         $tax_rates = GetPaid_Tax::get_default_tax_rates();
186 186
     }
187 187
 
188
-    return apply_filters( 'getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state );
188
+    return apply_filters('getpaid_get_item_tax_rates', $tax_rates, $item, $country, $state);
189 189
 }
190 190
 
191 191
 /**
@@ -195,23 +195,23 @@  discard block
 block discarded – undo
195 195
  * @param array $rates
196 196
  * @return array
197 197
  */
198
-function getpaid_filter_item_tax_rates( $item, $rates ) {
198
+function getpaid_filter_item_tax_rates($item, $rates) {
199 199
 
200 200
     $tax_class = $item->get_vat_class();
201 201
 
202
-    foreach ( $rates as $i => $rate ) {
202
+    foreach ($rates as $i => $rate) {
203 203
 
204
-        if ( $tax_class == '_reduced' ) {
205
-            $rates[ $i ]['rate'] = empty( $rate['reduced_rate'] ) ? 0 : $rate['reduced_rate'];
204
+        if ($tax_class == '_reduced') {
205
+            $rates[$i]['rate'] = empty($rate['reduced_rate']) ? 0 : $rate['reduced_rate'];
206 206
         }
207 207
 
208
-        if ( $tax_class == '_exempt' ) {
209
-            $rates[ $i ]['rate'] = 0;
208
+        if ($tax_class == '_exempt') {
209
+            $rates[$i]['rate'] = 0;
210 210
         }
211 211
 
212 212
     }
213 213
 
214
-    return apply_filters( 'getpaid_filter_item_tax_rates', $rates, $item );
214
+    return apply_filters('getpaid_filter_item_tax_rates', $rates, $item);
215 215
 }
216 216
 
217 217
 /**
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
  * @param array $rates
222 222
  * @return array
223 223
  */
224
-function getpaid_calculate_item_taxes( $amount, $rates ) {
224
+function getpaid_calculate_item_taxes($amount, $rates) {
225 225
 
226 226
     $is_inclusive = wpinv_prices_include_tax();
227
-    $taxes        = GetPaid_Tax::calc_tax( $amount, $rates, $is_inclusive );
227
+    $taxes        = GetPaid_Tax::calc_tax($amount, $rates, $is_inclusive);
228 228
 
229
-    return apply_filters( 'getpaid_calculate_taxes', $taxes, $amount, $rates );
229
+    return apply_filters('getpaid_calculate_taxes', $taxes, $amount, $rates);
230 230
 }
231 231
 
232 232
 /**
@@ -238,17 +238,17 @@  discard block
 block discarded – undo
238 238
  * @param float $recurring_tax_amount
239 239
  * @return array
240 240
  */
241
-function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) {
241
+function getpaid_prepare_item_tax($item, $tax_name, $tax_amount, $recurring_tax_amount) {
242 242
 
243
-    $initial_tax   = $tax_amount;
243
+    $initial_tax = $tax_amount;
244 244
 	$recurring_tax = 0;
245 245
 
246
-    if ( $item->is_recurring() ) {
246
+    if ($item->is_recurring()) {
247 247
 		$recurring_tax = $recurring_tax_amount;
248 248
 	}
249 249
 
250 250
 	return array(
251
-		'name'          => sanitize_text_field( $tax_name ),
251
+		'name'          => sanitize_text_field($tax_name),
252 252
 		'initial_tax'   => $initial_tax,
253 253
 		'recurring_tax' => $recurring_tax,
254 254
     );
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
  * @param string $vat_number
262 262
  * @return string
263 263
  */
264
-function wpinv_sanitize_vat_number( $vat_number ) {
265
-    return str_replace( array(' ', '.', '-', '_', ',' ), '', strtoupper( trim( $vat_number ) ) );
264
+function wpinv_sanitize_vat_number($vat_number) {
265
+    return str_replace(array(' ', '.', '-', '_', ','), '', strtoupper(trim($vat_number)));
266 266
 }
267 267
 
268 268
 /**
@@ -271,22 +271,22 @@  discard block
 block discarded – undo
271 271
  * @param string $vat_number
272 272
  * @return bool
273 273
  */
274
-function wpinv_regex_validate_vat_number( $vat_number ) {
274
+function wpinv_regex_validate_vat_number($vat_number) {
275 275
 
276
-    $country    = substr( $vat_number, 0, 2 );
277
-    $vatin      = substr( $vat_number, 2 );
278
-    $regexes    = wpinv_get_data( 'vat-number-regexes' );
276
+    $country    = substr($vat_number, 0, 2);
277
+    $vatin      = substr($vat_number, 2);
278
+    $regexes    = wpinv_get_data('vat-number-regexes');
279 279
 
280
-    if ( isset( $regexes[ $country ] ) ) {
280
+    if (isset($regexes[$country])) {
281 281
 
282
-        $regex = $regexes[ $country ];
282
+        $regex = $regexes[$country];
283 283
         $regex = '/^(?:' . $regex . ')$/';
284
-        return 1 === preg_match( $regex, $vatin );
284
+        return 1 === preg_match($regex, $vatin);
285 285
 
286 286
     }
287 287
 
288 288
     // Not an EU state, use filters to validate the number.
289
-    return apply_filters( 'wpinv_regex_validate_vat_number', true, $vat_number );
289
+    return apply_filters('wpinv_regex_validate_vat_number', true, $vat_number);
290 290
 }
291 291
 
292 292
 /**
@@ -295,29 +295,29 @@  discard block
 block discarded – undo
295 295
  * @param string $vat_number
296 296
  * @return bool
297 297
  */
298
-function wpinv_vies_validate_vat_number( $vat_number ) {
298
+function wpinv_vies_validate_vat_number($vat_number) {
299 299
 
300
-    $country    = substr( $vat_number, 0, 2 );
301
-    $vatin      = substr( $vat_number, 2 );
300
+    $country    = substr($vat_number, 0, 2);
301
+    $vatin      = substr($vat_number, 2);
302 302
 
303 303
     $url        = add_query_arg(
304 304
         array(
305
-            'ms'  => urlencode( $country ),
306
-            'iso' => urlencode( $country ),
307
-            'vat' => urlencode( $vatin ),
305
+            'ms'  => urlencode($country),
306
+            'iso' => urlencode($country),
307
+            'vat' => urlencode($vatin),
308 308
         ),
309 309
         'http://ec.europa.eu/taxation_customs/vies/viesquer.do'
310 310
     );
311 311
 
312
-    $response   = wp_remote_get( $url );
313
-    $response   = wp_remote_retrieve_body( $response );
312
+    $response   = wp_remote_get($url);
313
+    $response   = wp_remote_retrieve_body($response);
314 314
 
315 315
     // Fallback gracefully if the VIES website is down.
316
-    if ( empty( $response ) ) {
316
+    if (empty($response)) {
317 317
         return true;
318 318
     }
319 319
 
320
-    return 1 !== preg_match( '/invalid VAT number/i', $response );
320
+    return 1 !== preg_match('/invalid VAT number/i', $response);
321 321
 
322 322
 }
323 323
 
@@ -328,23 +328,23 @@  discard block
 block discarded – undo
328 328
  * @param string $country
329 329
  * @return bool
330 330
  */
331
-function wpinv_validate_vat_number( $vat_number, $country ) {
331
+function wpinv_validate_vat_number($vat_number, $country) {
332 332
 
333 333
     // Abort if we are not validating this.
334
-    if ( ! wpinv_should_validate_vat_number() || empty( $vat_number ) ) {
334
+    if (!wpinv_should_validate_vat_number() || empty($vat_number)) {
335 335
         return true;
336 336
     }
337 337
 
338 338
     // In case the vat number does not have a country code...
339
-    $vat_number = wpinv_sanitize_vat_number( $vat_number );
340
-    $_country   = substr( $vat_number, 0, 2 );
341
-    $_country   = $_country == wpinv_country_name( $_country );
339
+    $vat_number = wpinv_sanitize_vat_number($vat_number);
340
+    $_country   = substr($vat_number, 0, 2);
341
+    $_country   = $_country == wpinv_country_name($_country);
342 342
 
343
-    if ( $_country ) {
344
-        $vat_number = strtoupper( $country ) . $vat_number;
343
+    if ($_country) {
344
+        $vat_number = strtoupper($country) . $vat_number;
345 345
     }
346 346
 
347
-    return wpinv_regex_validate_vat_number( $vat_number ) && wpinv_vies_validate_vat_number( $vat_number );
347
+    return wpinv_regex_validate_vat_number($vat_number) && wpinv_vies_validate_vat_number($vat_number);
348 348
 }
349 349
 
350 350
 /**
@@ -353,40 +353,40 @@  discard block
 block discarded – undo
353 353
  * @return bool
354 354
  */
355 355
 function wpinv_should_validate_vat_number() {
356
-    $validate = wpinv_get_option( 'validate_vat_number' );
357
-	return ! empty( $validate );
356
+    $validate = wpinv_get_option('validate_vat_number');
357
+	return !empty($validate);
358 358
 }
359 359
 
360
-function wpinv_sales_tax_for_year( $year = null ) {
361
-    return wpinv_price( wpinv_format_amount( wpinv_get_sales_tax_for_year( $year ) ) );
360
+function wpinv_sales_tax_for_year($year = null) {
361
+    return wpinv_price(wpinv_format_amount(wpinv_get_sales_tax_for_year($year)));
362 362
 }
363 363
 
364
-function wpinv_get_sales_tax_for_year( $year = null ) {
364
+function wpinv_get_sales_tax_for_year($year = null) {
365 365
     global $wpdb;
366 366
 
367 367
     // Start at zero
368 368
     $tax = 0;
369 369
 
370
-    if ( ! empty( $year ) ) {
370
+    if (!empty($year)) {
371 371
         $args = array(
372 372
             'post_type'      => 'wpi_invoice',
373
-            'post_status'    => array( 'publish' ),
373
+            'post_status'    => array('publish'),
374 374
             'posts_per_page' => -1,
375 375
             'year'           => $year,
376 376
             'fields'         => 'ids'
377 377
         );
378 378
 
379
-        $payments    = get_posts( $args );
380
-        $payment_ids = implode( ',', $payments );
379
+        $payments    = get_posts($args);
380
+        $payment_ids = implode(',', $payments);
381 381
 
382
-        if ( count( $payments ) > 0 ) {
382
+        if (count($payments) > 0) {
383 383
             $sql = "SELECT SUM( meta_value ) FROM $wpdb->postmeta WHERE meta_key = '_wpinv_tax' AND post_id IN( $payment_ids )";
384
-            $tax = $wpdb->get_var( $sql );
384
+            $tax = $wpdb->get_var($sql);
385 385
         }
386 386
 
387 387
     }
388 388
 
389
-    return apply_filters( 'wpinv_get_sales_tax_for_year', $tax, $year );
389
+    return apply_filters('wpinv_get_sales_tax_for_year', $tax, $year);
390 390
 }
391 391
 
392 392
 function wpinv_is_cart_taxed() {
@@ -395,33 +395,33 @@  discard block
 block discarded – undo
395 395
 
396 396
 function wpinv_prices_show_tax_on_checkout() {
397 397
     return false; // TODO
398
-    $ret = ( wpinv_get_option( 'checkout_include_tax', false ) == 'yes' && wpinv_use_taxes() );
398
+    $ret = (wpinv_get_option('checkout_include_tax', false) == 'yes' && wpinv_use_taxes());
399 399
 
400
-    return apply_filters( 'wpinv_taxes_on_prices_on_checkout', $ret );
400
+    return apply_filters('wpinv_taxes_on_prices_on_checkout', $ret);
401 401
 }
402 402
 
403 403
 function wpinv_display_tax_rate() {
404
-    $ret = wpinv_use_taxes() && wpinv_get_option( 'display_tax_rate', false );
404
+    $ret = wpinv_use_taxes() && wpinv_get_option('display_tax_rate', false);
405 405
 
406
-    return apply_filters( 'wpinv_display_tax_rate', $ret );
406
+    return apply_filters('wpinv_display_tax_rate', $ret);
407 407
 }
408 408
 
409 409
 function wpinv_cart_needs_tax_address_fields() {
410
-    if( !wpinv_is_cart_taxed() )
410
+    if (!wpinv_is_cart_taxed())
411 411
         return false;
412 412
 
413
-    return ! did_action( 'wpinv_after_cc_fields', 'wpinv_default_cc_address_fields' );
413
+    return !did_action('wpinv_after_cc_fields', 'wpinv_default_cc_address_fields');
414 414
 }
415 415
 
416
-function wpinv_item_is_tax_exclusive( $item_id = 0 ) {
417
-    $ret = (bool)get_post_meta( $item_id, '_wpinv_tax_exclusive', false );
418
-    return apply_filters( 'wpinv_is_tax_exclusive', $ret, $item_id );
416
+function wpinv_item_is_tax_exclusive($item_id = 0) {
417
+    $ret = (bool) get_post_meta($item_id, '_wpinv_tax_exclusive', false);
418
+    return apply_filters('wpinv_is_tax_exclusive', $ret, $item_id);
419 419
 }
420 420
 
421
-function wpinv_currency_decimal_filter( $decimals = 2 ) {
421
+function wpinv_currency_decimal_filter($decimals = 2) {
422 422
     $currency = wpinv_get_currency();
423 423
 
424
-    switch ( $currency ) {
424
+    switch ($currency) {
425 425
         case 'RIAL' :
426 426
         case 'JPY' :
427 427
         case 'TWD' :
@@ -430,13 +430,13 @@  discard block
 block discarded – undo
430 430
             break;
431 431
     }
432 432
 
433
-    return apply_filters( 'wpinv_currency_decimal_count', $decimals, $currency );
433
+    return apply_filters('wpinv_currency_decimal_count', $decimals, $currency);
434 434
 }
435 435
 
436 436
 function wpinv_tax_amount() {
437 437
     $output = 0.00;
438 438
     
439
-    return apply_filters( 'wpinv_tax_amount', $output );
439
+    return apply_filters('wpinv_tax_amount', $output);
440 440
 }
441 441
 
442 442
 /**
@@ -444,25 +444,25 @@  discard block
 block discarded – undo
444 444
  * 
445 445
  * @param string|bool|null $vat_rule
446 446
  */
447
-function getpaid_filter_vat_rule( $vat_rule ) {
447
+function getpaid_filter_vat_rule($vat_rule) {
448 448
 
449
-    if ( empty( $vat_rule ) ) {        
449
+    if (empty($vat_rule)) {        
450 450
         return 'digital';
451 451
     }
452 452
 
453 453
     return $vat_rule;
454 454
 }
455
-add_filter( 'wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule' );
455
+add_filter('wpinv_get_item_vat_rule', 'getpaid_filter_vat_rule');
456 456
 
457 457
 /**
458 458
  * Filters the VAT class to ensure that each item has a VAT class.
459 459
  * 
460 460
  * @param string|bool|null $vat_rule
461 461
  */
462
-function getpaid_filter_vat_class( $vat_class ) {
463
-    return empty( $vat_class ) ? '_standard' : $vat_class;
462
+function getpaid_filter_vat_class($vat_class) {
463
+    return empty($vat_class) ? '_standard' : $vat_class;
464 464
 }
465
-add_filter( 'wpinv_get_item_vat_class', 'getpaid_filter_vat_class' );
465
+add_filter('wpinv_get_item_vat_class', 'getpaid_filter_vat_class');
466 466
 
467 467
 /**
468 468
  * Returns a list of all tax classes.
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
     return apply_filters(
475 475
         'getpaid_tax_classes',
476 476
         array(
477
-            '_standard' => __( 'Standard Tax Rate', 'invoicing' ),
478
-            '_reduced'  => __( 'Reduced Tax Rate', 'invoicing' ),
479
-            '_exempt'   => __( 'Tax Exempt', 'invoicing' ),
477
+            '_standard' => __('Standard Tax Rate', 'invoicing'),
478
+            '_reduced'  => __('Reduced Tax Rate', 'invoicing'),
479
+            '_exempt'   => __('Tax Exempt', 'invoicing'),
480 480
         )
481 481
     );
482 482
 
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
     return apply_filters(
493 493
         'getpaid_tax_rules',
494 494
         array(
495
-            'physical' => __( 'Physical Item', 'invoicing' ),
496
-            'digital'  => __( 'Digital Item', 'invoicing' ),
495
+            'physical' => __('Physical Item', 'invoicing'),
496
+            'digital'  => __('Digital Item', 'invoicing'),
497 497
         )
498 498
     );
499 499
 
@@ -505,15 +505,15 @@  discard block
 block discarded – undo
505 505
  * @param string $tax_class
506 506
  * @return string
507 507
  */
508
-function getpaid_get_tax_class_label( $tax_class ) {
508
+function getpaid_get_tax_class_label($tax_class) {
509 509
 
510 510
     $classes = getpaid_get_tax_classes();
511 511
 
512
-    if ( isset( $classes[ $tax_class ] ) ) {
513
-        return sanitize_text_field( $classes[ $tax_class ] );
512
+    if (isset($classes[$tax_class])) {
513
+        return sanitize_text_field($classes[$tax_class]);
514 514
     }
515 515
 
516
-    return sanitize_text_field( $tax_class );
516
+    return sanitize_text_field($tax_class);
517 517
 
518 518
 }
519 519
 
@@ -523,14 +523,14 @@  discard block
 block discarded – undo
523 523
  * @param string $tax_rule
524 524
  * @return string
525 525
  */
526
-function getpaid_get_tax_rule_label( $tax_rule ) {
526
+function getpaid_get_tax_rule_label($tax_rule) {
527 527
 
528 528
     $rules = getpaid_get_tax_rules();
529 529
 
530
-    if ( isset( $rules[ $tax_rule ] ) ) {
531
-        return sanitize_text_field( $rules[ $tax_rule ] );
530
+    if (isset($rules[$tax_rule])) {
531
+        return sanitize_text_field($rules[$tax_rule]);
532 532
     }
533 533
 
534
-    return sanitize_text_field( $tax_rule );
534
+    return sanitize_text_field($tax_rule);
535 535
 
536 536
 }
Please login to merge, or discard this patch.
includes/wpinv-item-functions.php 1 patch
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves an item by it's ID.
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * @param int the item ID to retrieve.
15 15
  * @return WPInv_Item|false
16 16
  */
17
-function wpinv_get_item_by_id( $id ) {
18
-    $item = wpinv_get_item( $id );
19
-    return empty( $item ) || $id != $item->get_id() ? false : $item;
17
+function wpinv_get_item_by_id($id) {
18
+    $item = wpinv_get_item($id);
19
+    return empty($item) || $id != $item->get_id() ? false : $item;
20 20
 }
21 21
 
22 22
 /**
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
  * 
25 25
  * @return WPInv_Item|false
26 26
  */
27
-function wpinv_get_item_by( $field = '', $value = '', $type = '' ) {
27
+function wpinv_get_item_by($field = '', $value = '', $type = '') {
28 28
 
29
-    if ( 'id' == strtolower( $field ) ) {
30
-        return wpinv_get_item_by_id( $field );
29
+    if ('id' == strtolower($field)) {
30
+        return wpinv_get_item_by_id($field);
31 31
     }
32 32
 
33
-    $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type );
34
-    return empty( $id ) ? false : wpinv_get_item( $id );
33
+    $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type);
34
+    return empty($id) ? false : wpinv_get_item($id);
35 35
 
36 36
 }
37 37
 
@@ -41,22 +41,22 @@  discard block
 block discarded – undo
41 41
  * @param int|WPInv_Item the item to retrieve.
42 42
  * @return WPInv_Item|false
43 43
  */
44
-function wpinv_get_item( $item = 0 ) {
44
+function wpinv_get_item($item = 0) {
45 45
 
46
-    if ( empty( $item ) ) {
46
+    if (empty($item)) {
47 47
         return false;
48 48
     }
49 49
 
50
-    $item = new WPInv_Item( $item );
50
+    $item = new WPInv_Item($item);
51 51
     return $item->exists() ? $item : false;
52 52
 
53 53
 }
54 54
 
55
-function wpinv_get_all_items( $args = array() ) {
55
+function wpinv_get_all_items($args = array()) {
56 56
 
57
-    $args = wp_parse_args( $args, array(
58
-        'status'         => array( 'publish' ),
59
-        'limit'          => get_option( 'posts_per_page' ),
57
+    $args = wp_parse_args($args, array(
58
+        'status'         => array('publish'),
59
+        'limit'          => get_option('posts_per_page'),
60 60
         'page'           => 1,
61 61
         'exclude'        => array(),
62 62
         'orderby'        => 'date',
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         'meta_query'     => array(),
66 66
         'return'         => 'objects',
67 67
         'paginate'       => false,
68
-    ) );
68
+    ));
69 69
 
70 70
     $wp_query_args = array(
71 71
         'post_type'      => 'wpi_item',
@@ -75,26 +75,26 @@  discard block
 block discarded – undo
75 75
         'fields'         => 'ids',
76 76
         'orderby'        => $args['orderby'],
77 77
         'order'          => $args['order'],
78
-        'paged'          => absint( $args['page'] ),
78
+        'paged'          => absint($args['page']),
79 79
     );
80 80
 
81
-    if ( ! empty( $args['exclude'] ) ) {
82
-        $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] );
81
+    if (!empty($args['exclude'])) {
82
+        $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']);
83 83
     }
84 84
 
85
-    if ( ! $args['paginate' ] ) {
85
+    if (!$args['paginate']) {
86 86
         $wp_query_args['no_found_rows'] = true;
87 87
     }
88 88
 
89
-    if ( ! empty( $args['search'] ) ) {
89
+    if (!empty($args['search'])) {
90 90
         $wp_query_args['s'] = $args['search'];
91 91
     }
92 92
 
93
-    if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) {
94
-        $types = wpinv_parse_list( $args['type'] );
93
+    if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) {
94
+        $types = wpinv_parse_list($args['type']);
95 95
         $wp_query_args['meta_query'][] = array(
96 96
             'key'     => '_wpinv_type',
97
-            'value'   => implode( ',', $types ),
97
+            'value'   => implode(',', $types),
98 98
             'compare' => 'IN',
99 99
         );
100 100
     }
@@ -102,17 +102,17 @@  discard block
 block discarded – undo
102 102
     $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args);
103 103
 
104 104
     // Get results.
105
-    $items = new WP_Query( $wp_query_args );
105
+    $items = new WP_Query($wp_query_args);
106 106
 
107
-    if ( 'objects' === $args['return'] ) {
108
-        $return = array_map( 'wpinv_get_item_by_id', $items->posts );
109
-    } elseif ( 'self' === $args['return'] ) {
107
+    if ('objects' === $args['return']) {
108
+        $return = array_map('wpinv_get_item_by_id', $items->posts);
109
+    } elseif ('self' === $args['return']) {
110 110
         return $items;
111 111
     } else {
112 112
         $return = $items->posts;
113 113
     }
114 114
 
115
-    if ( $args['paginate' ] ) {
115
+    if ($args['paginate']) {
116 116
         return (object) array(
117 117
             'items'      => $return,
118 118
             'total'         => $items->found_posts,
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 
125 125
 }
126 126
 
127
-function wpinv_is_free_item( $item_id = 0 ) {
128
-    if( empty( $item_id ) ) {
127
+function wpinv_is_free_item($item_id = 0) {
128
+    if (empty($item_id)) {
129 129
         return false;
130 130
     }
131 131
 
132
-    $item = new WPInv_Item( $item_id );
132
+    $item = new WPInv_Item($item_id);
133 133
     
134 134
     return $item->is_free();
135 135
 }
@@ -139,21 +139,21 @@  discard block
 block discarded – undo
139 139
  * 
140 140
  * @param WP_Post|WPInv_Item|Int $item The item to check for.
141 141
  */
142
-function wpinv_item_is_editable( $item = 0 ) {
142
+function wpinv_item_is_editable($item = 0) {
143 143
 
144 144
     // Fetch the item.
145
-    $item = new WPInv_Item( $item );
145
+    $item = new WPInv_Item($item);
146 146
 
147 147
     // Check if it is editable.
148 148
     return $item->is_editable();
149 149
 }
150 150
 
151
-function wpinv_get_item_price( $item_id = 0 ) {
152
-    if( empty( $item_id ) ) {
151
+function wpinv_get_item_price($item_id = 0) {
152
+    if (empty($item_id)) {
153 153
         return false;
154 154
     }
155 155
 
156
-    $item = new WPInv_Item( $item_id );
156
+    $item = new WPInv_Item($item_id);
157 157
     
158 158
     return $item->get_price();
159 159
 }
@@ -163,96 +163,96 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @param WPInv_Item|int $item
165 165
  */
166
-function wpinv_is_recurring_item( $item = 0 ) {
167
-    $item = new WPInv_Item( $item ); 
166
+function wpinv_is_recurring_item($item = 0) {
167
+    $item = new WPInv_Item($item); 
168 168
     return $item->is_recurring();
169 169
 }
170 170
 
171
-function wpinv_item_price( $item_id = 0 ) {
172
-    if( empty( $item_id ) ) {
171
+function wpinv_item_price($item_id = 0) {
172
+    if (empty($item_id)) {
173 173
         return false;
174 174
     }
175 175
 
176
-    $price = wpinv_get_item_price( $item_id );
177
-    $price = wpinv_price( wpinv_format_amount( $price ) );
176
+    $price = wpinv_get_item_price($item_id);
177
+    $price = wpinv_price(wpinv_format_amount($price));
178 178
     
179
-    return apply_filters( 'wpinv_item_price', $price, $item_id );
179
+    return apply_filters('wpinv_item_price', $price, $item_id);
180 180
 }
181 181
 
182
-function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) {
183
-    if ( is_null( $amount_override ) ) {
184
-        $original_price = get_post_meta( $item_id, '_wpinv_price', true );
182
+function wpinv_get_item_final_price($item_id = 0, $amount_override = null) {
183
+    if (is_null($amount_override)) {
184
+        $original_price = get_post_meta($item_id, '_wpinv_price', true);
185 185
     } else {
186 186
         $original_price = $amount_override;
187 187
     }
188 188
     
189 189
     $price = $original_price;
190 190
 
191
-    return apply_filters( 'wpinv_get_item_final_price', $price, $item_id );
191
+    return apply_filters('wpinv_get_item_final_price', $price, $item_id);
192 192
 }
193 193
 
194
-function wpinv_item_custom_singular_name( $item_id ) {
195
-    if( empty( $item_id ) ) {
194
+function wpinv_item_custom_singular_name($item_id) {
195
+    if (empty($item_id)) {
196 196
         return false;
197 197
     }
198 198
 
199
-    $item = new WPInv_Item( $item_id );
199
+    $item = new WPInv_Item($item_id);
200 200
     
201 201
     return $item->get_custom_singular_name();
202 202
 }
203 203
 
204 204
 function wpinv_get_item_types() {
205 205
     $item_types = array(
206
-            'custom'    => __( 'Standard', 'invoicing' ),
207
-            'fee'       => __( 'Fee', 'invoicing' ),
206
+            'custom'    => __('Standard', 'invoicing'),
207
+            'fee'       => __('Fee', 'invoicing'),
208 208
         );
209
-    return apply_filters( 'wpinv_get_item_types', $item_types );
209
+    return apply_filters('wpinv_get_item_types', $item_types);
210 210
 }
211 211
 
212 212
 function wpinv_item_types() {
213 213
     $item_types = wpinv_get_item_types();
214 214
     
215
-    return ( !empty( $item_types ) ? array_keys( $item_types ) : array() );
215
+    return (!empty($item_types) ? array_keys($item_types) : array());
216 216
 }
217 217
 
218
-function wpinv_get_item_type( $item_id ) {
219
-    if( empty( $item_id ) ) {
218
+function wpinv_get_item_type($item_id) {
219
+    if (empty($item_id)) {
220 220
         return false;
221 221
     }
222 222
 
223
-    $item = new WPInv_Item( $item_id );
223
+    $item = new WPInv_Item($item_id);
224 224
     
225 225
     return $item->get_type();
226 226
 }
227 227
 
228
-function wpinv_item_type( $item_id ) {
228
+function wpinv_item_type($item_id) {
229 229
     $item_types = wpinv_get_item_types();
230 230
     
231
-    $item_type = wpinv_get_item_type( $item_id );
231
+    $item_type = wpinv_get_item_type($item_id);
232 232
     
233
-    if ( empty( $item_type ) ) {
233
+    if (empty($item_type)) {
234 234
         $item_type = '-';
235 235
     }
236 236
     
237
-    $item_type = isset( $item_types[$item_type] ) ? $item_types[$item_type] : __( $item_type, 'invoicing' );
237
+    $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing');
238 238
 
239
-    return apply_filters( 'wpinv_item_type', $item_type, $item_id );
239
+    return apply_filters('wpinv_item_type', $item_type, $item_id);
240 240
 }
241 241
 
242
-function wpinv_get_random_item( $post_ids = true ) {
243
-    wpinv_get_random_items( 1, $post_ids );
242
+function wpinv_get_random_item($post_ids = true) {
243
+    wpinv_get_random_items(1, $post_ids);
244 244
 }
245 245
 
246
-function wpinv_get_random_items( $num = 3, $post_ids = true ) {
247
-    if ( $post_ids ) {
248
-        $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids' );
246
+function wpinv_get_random_items($num = 3, $post_ids = true) {
247
+    if ($post_ids) {
248
+        $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num, 'fields' => 'ids');
249 249
     } else {
250
-        $args = array( 'post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num );
250
+        $args = array('post_type' => 'wpi_item', 'orderby' => 'rand', 'post_count' => $num);
251 251
     }
252 252
     
253
-    $args  = apply_filters( 'wpinv_get_random_items', $args );
253
+    $args = apply_filters('wpinv_get_random_items', $args);
254 254
     
255
-    return get_posts( $args );
255
+    return get_posts($args);
256 256
 }
257 257
 
258 258
 /**
@@ -261,13 +261,13 @@  discard block
 block discarded – undo
261 261
  * @param WPInv_Item|int $item
262 262
  * @param bool $html
263 263
  */
264
-function wpinv_get_item_suffix( $item, $html = true ) {
264
+function wpinv_get_item_suffix($item, $html = true) {
265 265
 
266
-    $item   = new WPInv_Item( $item );
267
-    $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '';
268
-    $suffix = $html ? $suffix : strip_tags( $suffix );
266
+    $item   = new WPInv_Item($item);
267
+    $suffix = $item->is_recurring() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '';
268
+    $suffix = $html ? $suffix : strip_tags($suffix);
269 269
 
270
-    return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html );
270
+    return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html);
271 271
 }
272 272
 
273 273
 /**
@@ -276,9 +276,9 @@  discard block
 block discarded – undo
276 276
  * @param WPInv_Item|int $item
277 277
  * @param bool $force_delete
278 278
  */
279
-function wpinv_remove_item( $item = 0, $force_delete = false ) {
280
-    $item = new WPInv_Item( $item );
281
-    $item->delete( $force_delete );
279
+function wpinv_remove_item($item = 0, $force_delete = false) {
280
+    $item = new WPInv_Item($item);
281
+    $item->delete($force_delete);
282 282
 }
283 283
 
284 284
 /**
@@ -317,45 +317,45 @@  discard block
 block discarded – undo
317 317
  * @param bool $wp_error whether or not to return a WP_Error on failure.
318 318
  * @return bool|WP_Error|WPInv_Item
319 319
  */
320
-function wpinv_create_item( $args = array(), $wp_error = false ) {
320
+function wpinv_create_item($args = array(), $wp_error = false) {
321 321
 
322 322
     // Prepare the item.
323
-    if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) {
324
-        $type = empty( $args['type'] ) ? 'custom' : $args['type'];
325
-        $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type );
323
+    if (!empty($args['custom_id']) && empty($args['ID'])) {
324
+        $type = empty($args['type']) ? 'custom' : $args['type'];
325
+        $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type);
326 326
 
327
-        if ( ! empty( $item ) ) {
327
+        if (!empty($item)) {
328 328
             $args['ID'] = $item->get_id();
329 329
         }
330 330
 
331 331
     }
332 332
 
333 333
     // Do we have an item?
334
-    if ( ! empty( $args['ID'] ) ) {
335
-        $item = new WPInv_Item( $args['ID'] );
334
+    if (!empty($args['ID'])) {
335
+        $item = new WPInv_Item($args['ID']);
336 336
     } else {
337 337
         $item = new WPInv_Item();
338 338
     }
339 339
 
340 340
     // Do we have an error?
341
-    if ( ! empty( $item->last_error ) ) {
342
-        return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false;
341
+    if (!empty($item->last_error)) {
342
+        return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false;
343 343
     }
344 344
 
345 345
     // Update item props.
346
-    $item->set_props( $args );
346
+    $item->set_props($args);
347 347
 
348 348
     // Save the item.
349 349
     $item->save();
350 350
 
351 351
     // Do we have an error?
352
-    if ( ! empty( $item->last_error ) ) {
353
-        return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false;
352
+    if (!empty($item->last_error)) {
353
+        return $wp_error ? new WP_Error('not_saved', $item->last_error) : false;
354 354
     }
355 355
 
356 356
     // Was the item saved?
357
-    if ( ! $item->get_id() ) {
358
-        return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false;
357
+    if (!$item->get_id()) {
358
+        return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false;
359 359
     }
360 360
 
361 361
     return $item;
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
  * 
368 368
  * @see wpinv_create_item()
369 369
  */
370
-function wpinv_update_item( $args = array(), $wp_error = false ) {
371
-    return wpinv_create_item( $args, $wp_error );
370
+function wpinv_update_item($args = array(), $wp_error = false) {
371
+    return wpinv_create_item($args, $wp_error);
372 372
 }
373 373
 
374 374
 /**
375 375
  * Sanitizes a recurring period
376 376
  */
377
-function getpaid_sanitize_recurring_period( $period, $full = false ) {
377
+function getpaid_sanitize_recurring_period($period, $full = false) {
378 378
 
379 379
     $periods = array(
380 380
         'D' => 'day',
@@ -383,11 +383,11 @@  discard block
 block discarded – undo
383 383
         'Y' => 'year',
384 384
     );
385 385
 
386
-    if ( ! isset( $periods[ $period ] ) ) {
386
+    if (!isset($periods[$period])) {
387 387
         $period = 'D';
388 388
     }
389 389
 
390
-    return $full ? $periods[ $period ] : $period;
390
+    return $full ? $periods[$period] : $period;
391 391
 
392 392
 }
393 393
 
@@ -396,34 +396,34 @@  discard block
 block discarded – undo
396 396
  * 
397 397
  * @param WPInv_Item|GetPaid_Form_Item $item
398 398
  */
399
-function getpaid_item_recurring_price_help_text( $item, $currency = '' ) {
399
+function getpaid_item_recurring_price_help_text($item, $currency = '') {
400 400
 
401 401
     // Abort if it is not recurring.
402
-    if ( ! $item->is_recurring() ) {
402
+    if (!$item->is_recurring()) {
403 403
         return '';
404 404
     }
405 405
 
406
-    $initial_price   = wpinv_price( $item->get_initial_price(), $currency );
407
-    $recurring_price = wpinv_price( $item->get_recurring_price(), $currency );
408
-    $period          = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' );
406
+    $initial_price   = wpinv_price($item->get_initial_price(), $currency);
407
+    $recurring_price = wpinv_price($item->get_recurring_price(), $currency);
408
+    $period          = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '');
409 409
     $initial_class   = 'getpaid-item-initial-price';
410 410
     $recurring_class = 'getpaid-item-recurring-price';
411 411
 
412
-    if ( $item instanceof GetPaid_Form_Item ) {
413
-        $initial_price   = wpinv_price( $item->get_sub_total(), $currency );
414
-        $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency );
412
+    if ($item instanceof GetPaid_Form_Item) {
413
+        $initial_price   = wpinv_price($item->get_sub_total(), $currency);
414
+        $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency);
415 415
     }
416 416
 
417 417
     // For free trial items.
418
-    if ( $item->has_free_trial() ) {
419
-        $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() );
418
+    if ($item->has_free_trial()) {
419
+        $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval());
420 420
 
421
-        if ( 0 == $item->get_initial_price() ) {
421
+        if (0 == $item->get_initial_price()) {
422 422
 
423 423
             return sprintf(
424 424
 
425 425
                 // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period
426
-                _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ),
426
+                _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'),
427 427
                 $trial_period,
428 428
                 "<span class='$recurring_class'>$recurring_price</span>",
429 429
                 $period
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
         return sprintf(
436 436
 
437 437
             // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period
438
-            _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ),
438
+            _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'),
439 439
             "<span class='$initial_class'>$initial_price</span>",
440 440
             $trial_period,
441 441
             "<span class='$recurring_class'>$recurring_price</span>",
@@ -445,12 +445,12 @@  discard block
 block discarded – undo
445 445
 
446 446
     }
447 447
 
448
-    if ( $initial_price == $recurring_price ) {
448
+    if ($initial_price == $recurring_price) {
449 449
 
450 450
         return sprintf(
451 451
 
452 452
             // translators: $1: is the recurring price, $2: is the susbcription period
453
-            _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ),
453
+            _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'),
454 454
             "<span class='$recurring_class'>$recurring_price</span>",
455 455
             $period
456 456
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
     return sprintf(
462 462
 
463 463
         // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period
464
-        _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ),
464
+        _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'),
465 465
         "<span class='$initial_class'>$initial_price</span>",
466 466
         "<span class='$recurring_class'>$recurring_price</span>",
467 467
         $period
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
  */
98 98
 function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
99 99
 
100
-	$invoice_statuses = array(
101
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
100
+    $invoice_statuses = array(
101
+        'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
102 102
         'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
103 103
         'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
104
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
105
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
106
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
104
+        'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
105
+        'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
106
+        'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
107 107
         'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
108 108
         'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
109 109
     );
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         $invoice = $invoice->get_post_type();
121 121
     }
122 122
 
123
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
123
+    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
124 124
 }
125 125
 
126 126
 /**
@@ -238,25 +238,25 @@  discard block
 block discarded – undo
238 238
  * @return string
239 239
  */
240 240
 function getpaid_get_price_format() {
241
-	$currency_pos = wpinv_currency_position();
242
-	$format       = '%1$s%2$s';
243
-
244
-	switch ( $currency_pos ) {
245
-		case 'left':
246
-			$format = '%1$s%2$s';
247
-			break;
248
-		case 'right':
249
-			$format = '%2$s%1$s';
250
-			break;
251
-		case 'left_space':
252
-			$format = '%1$s&nbsp;%2$s';
253
-			break;
254
-		case 'right_space':
255
-			$format = '%2$s&nbsp;%1$s';
256
-			break;
257
-	}
258
-
259
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
241
+    $currency_pos = wpinv_currency_position();
242
+    $format       = '%1$s%2$s';
243
+
244
+    switch ( $currency_pos ) {
245
+        case 'left':
246
+            $format = '%1$s%2$s';
247
+            break;
248
+        case 'right':
249
+            $format = '%2$s%1$s';
250
+            break;
251
+        case 'left_space':
252
+            $format = '%1$s&nbsp;%2$s';
253
+            break;
254
+        case 'right_space':
255
+            $format = '%2$s&nbsp;%1$s';
256
+            break;
257
+    }
258
+
259
+    return apply_filters( 'getpaid_price_format', $format, $currency_pos );
260 260
 }
261 261
 
262 262
 /**
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
  * @param mixed  $value Value.
360 360
  */
361 361
 function getpaid_maybe_define_constant( $name, $value ) {
362
-	if ( ! defined( $name ) ) {
363
-		define( $name, $value );
364
-	}
362
+    if ( ! defined( $name ) ) {
363
+        define( $name, $value );
364
+    }
365 365
 }
366 366
 
367 367
 function wpinv_get_php_arg_separator_output() {
368
-	return ini_get( 'arg_separator.output' );
368
+    return ini_get( 'arg_separator.output' );
369 369
 }
370 370
 
371 371
 function wpinv_rgb_from_hex( $color ) {
@@ -716,11 +716,11 @@  discard block
 block discarded – undo
716 716
         $list = array();
717 717
     }
718 718
 
719
-	if ( ! is_array( $list ) ) {
720
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
721
-	}
719
+    if ( ! is_array( $list ) ) {
720
+        return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
721
+    }
722 722
 
723
-	return $list;
723
+    return $list;
724 724
 }
725 725
 
726 726
 /**
@@ -740,9 +740,9 @@  discard block
 block discarded – undo
740 740
     }
741 741
 
742 742
     $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
743
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
743
+    wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
744 744
 
745
-	return $data;
745
+    return $data;
746 746
 }
747 747
 
748 748
 /**
@@ -771,17 +771,17 @@  discard block
 block discarded – undo
771 771
  */
772 772
 function wpinv_clean( $var ) {
773 773
 
774
-	if ( is_array( $var ) ) {
775
-		return array_map( 'wpinv_clean', $var );
774
+    if ( is_array( $var ) ) {
775
+        return array_map( 'wpinv_clean', $var );
776 776
     }
777 777
 
778 778
     if ( is_object( $var ) ) {
779
-		$object_vars = get_object_vars( $var );
780
-		foreach ( $object_vars as $property_name => $property_value ) {
781
-			$var->$property_name = wpinv_clean( $property_value );
779
+        $object_vars = get_object_vars( $var );
780
+        foreach ( $object_vars as $property_name => $property_value ) {
781
+            $var->$property_name = wpinv_clean( $property_value );
782 782
         }
783 783
         return $var;
784
-	}
784
+    }
785 785
     
786 786
     return is_string( $var ) ? sanitize_text_field( $var ) : $var;
787 787
 }
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
  */
795 795
 function getpaid_convert_price_string_to_options( $str ) {
796 796
 
797
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
797
+    $raw_options = array_map( 'trim', explode( ',', $str ) );
798 798
     $options     = array();
799 799
 
800 800
     foreach ( $raw_options as $option ) {
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
  * @return string
873 873
  */
874 874
 function getpaid_date_format() {
875
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
875
+    return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
876 876
 }
877 877
 
878 878
 /**
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
  * @return string
882 882
  */
883 883
 function getpaid_time_format() {
884
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
884
+    return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
885 885
 }
886 886
 
887 887
 /**
@@ -894,15 +894,15 @@  discard block
 block discarded – undo
894 894
 function getpaid_limit_length( $string, $limit ) {
895 895
     $str_limit = $limit - 3;
896 896
 
897
-	if ( function_exists( 'mb_strimwidth' ) ) {
898
-		if ( mb_strlen( $string ) > $limit ) {
899
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
900
-		}
901
-	} else {
902
-		if ( strlen( $string ) > $limit ) {
903
-			$string = substr( $string, 0, $str_limit ) . '...';
904
-		}
905
-	}
897
+    if ( function_exists( 'mb_strimwidth' ) ) {
898
+        if ( mb_strlen( $string ) > $limit ) {
899
+            $string = mb_strimwidth( $string, 0, $str_limit ) . '...';
900
+        }
901
+    } else {
902
+        if ( strlen( $string ) > $limit ) {
903
+            $string = substr( $string, 0, $str_limit ) . '...';
904
+        }
905
+    }
906 906
     return $string;
907 907
 
908 908
 }
Please login to merge, or discard this patch.
Spacing   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Are we supporting item quantities?
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wpinv_get_ip() {
22 22
 
23
-    if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
24
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) );
23
+    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
24
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP']));
25 25
     }
26 26
 
27
-    if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
27
+    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
28 28
         // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
29 29
         // Make sure we always only send through the first IP in the list which should always be the client IP.
30
-        return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) );
30
+        return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR']))))));
31 31
     }
32 32
 
33
-    if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
34
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
33
+    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
34
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP']));
35 35
     }
36 36
 
37
-    if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
38
-        return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
37
+    if (isset($_SERVER['REMOTE_ADDR'])) {
38
+        return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
39 39
     }
40 40
 
41 41
     return '';
42 42
 }
43 43
 
44 44
 function wpinv_get_user_agent() {
45
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
46
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
45
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
46
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
47 47
     } else {
48 48
         $user_agent = '';
49 49
     }
50 50
 
51
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
51
+    return apply_filters('wpinv_get_user_agent', $user_agent);
52 52
 }
53 53
 
54 54
 /**
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
  * 
57 57
  * @param string $amount The amount to sanitize.
58 58
  */
59
-function wpinv_sanitize_amount( $amount ) {
59
+function wpinv_sanitize_amount($amount) {
60 60
 
61 61
     // Format decimals.
62
-    $amount = str_replace( wpinv_decimal_separator(), '.', $amount );
62
+    $amount = str_replace(wpinv_decimal_separator(), '.', $amount);
63 63
 
64 64
     // Remove thousands.
65
-    $amount = str_replace( wpinv_thousands_separator(), '', $amount );
65
+    $amount = str_replace(wpinv_thousands_separator(), '', $amount);
66 66
 
67 67
     // Cast the remaining to a float.
68
-    return (float) preg_replace( '/[^0-9\.\-]/', '', $amount );
68
+    return (float) preg_replace('/[^0-9\.\-]/', '', $amount);
69 69
 
70 70
 }
71 71
 
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
  * @param float $amount
76 76
  * @param int|null $decimals
77 77
  */
78
-function wpinv_round_amount( $amount, $decimals = null ) {
78
+function wpinv_round_amount($amount, $decimals = null) {
79 79
 
80
-    if ( $decimals === null ) {
80
+    if ($decimals === null) {
81 81
         $decimals = wpinv_decimals();
82 82
     }
83 83
     
84
-    $amount = round( (float) $amount, absint( $decimals ) );
84
+    $amount = round((float) $amount, absint($decimals));
85 85
 
86
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
86
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
87 87
 }
88 88
 
89 89
 /**
@@ -95,32 +95,32 @@  discard block
 block discarded – undo
95 95
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
96 96
  * @return array
97 97
  */
98
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
98
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
99 99
 
100 100
 	$invoice_statuses = array(
101
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
102
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
103
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
104
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
105
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
106
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
107
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
108
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
101
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
102
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
103
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
104
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
105
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
106
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
107
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
108
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
109 109
     );
110 110
 
111
-    if ( $draft ) {
112
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
111
+    if ($draft) {
112
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
113 113
     }
114 114
 
115
-    if ( $trashed ) {
116
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
115
+    if ($trashed) {
116
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
117 117
     }
118 118
 
119
-    if ( $invoice instanceof WPInv_Invoice ) {
119
+    if ($invoice instanceof WPInv_Invoice) {
120 120
         $invoice = $invoice->get_post_type();
121 121
     }
122 122
 
123
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
123
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
124 124
 }
125 125
 
126 126
 /**
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
  * @param string $status The raw status
130 130
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
131 131
  */
132
-function wpinv_status_nicename( $status, $invoice = false ) {
133
-    $statuses = wpinv_get_invoice_statuses( true, true, $invoice );
134
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : $status;
132
+function wpinv_status_nicename($status, $invoice = false) {
133
+    $statuses = wpinv_get_invoice_statuses(true, true, $invoice);
134
+    $status   = isset($statuses[$status]) ? $statuses[$status] : $status;
135 135
 
136
-    return sanitize_text_field( $status );
136
+    return sanitize_text_field($status);
137 137
 }
138 138
 
139 139
 /**
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
  * 
142 142
  * @param string $current
143 143
  */
144
-function wpinv_get_currency( $current = '' ) {
144
+function wpinv_get_currency($current = '') {
145 145
 
146
-    if ( empty( $current ) ) {
147
-        $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
146
+    if (empty($current)) {
147
+        $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
148 148
     }
149 149
 
150
-    return trim( strtoupper( $current ) );
150
+    return trim(strtoupper($current));
151 151
 }
152 152
 
153 153
 /**
@@ -155,25 +155,25 @@  discard block
 block discarded – undo
155 155
  * 
156 156
  * @param string|null $currency The currency code. Defaults to the default currency.
157 157
  */
158
-function wpinv_currency_symbol( $currency = null ) {
158
+function wpinv_currency_symbol($currency = null) {
159 159
 
160 160
     // Prepare the currency.
161
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
161
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
162 162
 
163 163
     // Fetch all symbols.
164 164
     $symbols = wpinv_get_currency_symbols();
165 165
 
166 166
     // Fetch this currencies symbol.
167
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
167
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
168 168
 
169 169
     // Filter the symbol.
170
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
170
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
171 171
 }
172 172
 
173 173
 function wpinv_currency_position() {
174
-    $position = wpinv_get_option( 'currency_position', 'left' );
174
+    $position = wpinv_get_option('currency_position', 'left');
175 175
     
176
-    return apply_filters( 'wpinv_currency_position', $position );
176
+    return apply_filters('wpinv_currency_position', $position);
177 177
 }
178 178
 
179 179
 /**
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
  * 
182 182
  * @param $string|null $current
183 183
  */
184
-function wpinv_thousands_separator( $current = null ) {
184
+function wpinv_thousands_separator($current = null) {
185 185
 
186
-    if ( null == $current ) {
187
-        $current = wpinv_get_option( 'thousands_separator', '.' );
186
+    if (null == $current) {
187
+        $current = wpinv_get_option('thousands_separator', '.');
188 188
     }
189 189
 
190
-    return trim( $current );
190
+    return trim($current);
191 191
 }
192 192
 
193 193
 /**
@@ -195,13 +195,13 @@  discard block
 block discarded – undo
195 195
  * 
196 196
  * @param $string|null $current
197 197
  */
198
-function wpinv_decimal_separator( $current = null ) {
198
+function wpinv_decimal_separator($current = null) {
199 199
 
200
-    if ( null == $current ) {
201
-        $current = wpinv_get_option( 'decimal_separator', '.' );
200
+    if (null == $current) {
201
+        $current = wpinv_get_option('decimal_separator', '.');
202 202
     }
203 203
     
204
-    return trim( $current );
204
+    return trim($current);
205 205
 }
206 206
 
207 207
 /**
@@ -209,27 +209,27 @@  discard block
 block discarded – undo
209 209
  * 
210 210
  * @param $string|null $current
211 211
  */
212
-function wpinv_decimals( $current = null ) {
212
+function wpinv_decimals($current = null) {
213 213
 
214
-    if ( null == $current ) {
215
-        $current = wpinv_get_option( 'decimals', 2 );
214
+    if (null == $current) {
215
+        $current = wpinv_get_option('decimals', 2);
216 216
     }
217 217
     
218
-    return absint( $current );
218
+    return absint($current);
219 219
 }
220 220
 
221 221
 /**
222 222
  * Retrieves a list of all supported currencies.
223 223
  */
224 224
 function wpinv_get_currencies() {
225
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
225
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
226 226
 }
227 227
 
228 228
 /**
229 229
  * Retrieves a list of all currency symbols.
230 230
  */
231 231
 function wpinv_get_currency_symbols() {
232
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
232
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
233 233
 }
234 234
 
235 235
 /**
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	$currency_pos = wpinv_currency_position();
242 242
 	$format       = '%1$s%2$s';
243 243
 
244
-	switch ( $currency_pos ) {
244
+	switch ($currency_pos) {
245 245
 		case 'left':
246 246
 			$format = '%1$s%2$s';
247 247
 			break;
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 			break;
257 257
 	}
258 258
 
259
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
259
+	return apply_filters('getpaid_price_format', $format, $currency_pos);
260 260
 }
261 261
 
262 262
 /**
@@ -266,25 +266,25 @@  discard block
 block discarded – undo
266 266
  * @param  string $currency Currency.
267 267
  * @return string
268 268
  */
269
-function wpinv_price( $amount = 0, $currency = '' ) {
269
+function wpinv_price($amount = 0, $currency = '') {
270 270
 
271 271
     // Backwards compatibility.
272
-    $amount             = floatval( wpinv_sanitize_amount( $amount ) );
272
+    $amount             = floatval(wpinv_sanitize_amount($amount));
273 273
 
274 274
     // Prepare variables.
275
-    $currency           = wpinv_get_currency( $currency );
275
+    $currency           = wpinv_get_currency($currency);
276 276
     $amount             = (float) $amount;
277 277
     $unformatted_amount = $amount;
278 278
     $negative           = $amount < 0;
279
-    $amount             = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) );
280
-    $amount             = wpinv_format_amount( $amount );
279
+    $amount             = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount));
280
+    $amount             = wpinv_format_amount($amount);
281 281
 
282 282
     // Format the amount.
283 283
     $format             = getpaid_get_price_format();
284
-    $formatted_amount   = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount );
284
+    $formatted_amount   = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount);
285 285
 
286 286
     // Filter the formatting.
287
-    return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount );
287
+    return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount);
288 288
 }
289 289
 
290 290
 /**
@@ -295,33 +295,33 @@  discard block
 block discarded – undo
295 295
  * @param  bool     $calculate Whether or not to apply separators.
296 296
  * @return string
297 297
  */
298
-function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) {
298
+function wpinv_format_amount($amount, $decimals = null, $calculate = false) {
299 299
     $thousands_sep = wpinv_thousands_separator();
300 300
     $decimal_sep   = wpinv_decimal_separator();
301
-    $decimals      = wpinv_decimals( $decimals );
301
+    $decimals      = wpinv_decimals($decimals);
302 302
 
303 303
     // Format decimals.
304
-    $amount = str_replace( $decimal_sep, '.', $amount );
304
+    $amount = str_replace($decimal_sep, '.', $amount);
305 305
 
306 306
     // Remove thousands.
307
-    $amount = str_replace( $thousands_sep, '', $amount );
307
+    $amount = str_replace($thousands_sep, '', $amount);
308 308
 
309 309
     // Cast the remaining to a float.
310
-    $amount = floatval( $amount );
310
+    $amount = floatval($amount);
311 311
 
312
-    if ( $calculate ) {
312
+    if ($calculate) {
313 313
         return $amount;
314 314
     }
315 315
 
316 316
     // Fomart the amount.
317
-    return number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
317
+    return number_format($amount, $decimals, $decimal_sep, $thousands_sep);
318 318
 }
319 319
 
320
-function wpinv_sanitize_key( $key ) {
320
+function wpinv_sanitize_key($key) {
321 321
     $raw_key = $key;
322
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
322
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
323 323
 
324
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
324
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
325 325
 }
326 326
 
327 327
 /**
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
  * 
330 330
  * @param $str the file whose extension should be retrieved.
331 331
  */
332
-function wpinv_get_file_extension( $str ) {
333
-    $filetype = wp_check_filetype( $str );
332
+function wpinv_get_file_extension($str) {
333
+    $filetype = wp_check_filetype($str);
334 334
     return $filetype['ext'];
335 335
 }
336 336
 
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
  * 
340 340
  * @param string $string
341 341
  */
342
-function wpinv_string_is_image_url( $string ) {
343
-    $extension = strtolower( wpinv_get_file_extension( $string ) );
344
-    return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true );
342
+function wpinv_string_is_image_url($string) {
343
+    $extension = strtolower(wpinv_get_file_extension($string));
344
+    return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true);
345 345
 }
346 346
 
347 347
 /**
348 348
  * Returns the current URL.
349 349
  */
350 350
 function wpinv_get_current_page_url() {
351
-    return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
351
+    return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
352 352
 }
353 353
 
354 354
 /**
@@ -358,46 +358,46 @@  discard block
 block discarded – undo
358 358
  * @param string $name  Constant name.
359 359
  * @param mixed  $value Value.
360 360
  */
361
-function getpaid_maybe_define_constant( $name, $value ) {
362
-	if ( ! defined( $name ) ) {
363
-		define( $name, $value );
361
+function getpaid_maybe_define_constant($name, $value) {
362
+	if (!defined($name)) {
363
+		define($name, $value);
364 364
 	}
365 365
 }
366 366
 
367 367
 function wpinv_get_php_arg_separator_output() {
368
-	return ini_get( 'arg_separator.output' );
368
+	return ini_get('arg_separator.output');
369 369
 }
370 370
 
371
-function wpinv_rgb_from_hex( $color ) {
372
-    $color = str_replace( '#', '', $color );
371
+function wpinv_rgb_from_hex($color) {
372
+    $color = str_replace('#', '', $color);
373 373
 
374 374
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
375
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
376
-    if ( empty( $color ) ) {
375
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
376
+    if (empty($color)) {
377 377
         return NULL;
378 378
     }
379 379
 
380
-    $color = str_split( $color );
380
+    $color = str_split($color);
381 381
 
382 382
     $rgb      = array();
383
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
384
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
385
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
383
+    $rgb['R'] = hexdec($color[0] . $color[1]);
384
+    $rgb['G'] = hexdec($color[2] . $color[3]);
385
+    $rgb['B'] = hexdec($color[4] . $color[5]);
386 386
 
387 387
     return $rgb;
388 388
 }
389 389
 
390
-function wpinv_hex_darker( $color, $factor = 30 ) {
391
-    $base  = wpinv_rgb_from_hex( $color );
390
+function wpinv_hex_darker($color, $factor = 30) {
391
+    $base  = wpinv_rgb_from_hex($color);
392 392
     $color = '#';
393 393
 
394
-    foreach ( $base as $k => $v ) {
394
+    foreach ($base as $k => $v) {
395 395
         $amount      = $v / 100;
396
-        $amount      = round( $amount * $factor );
396
+        $amount      = round($amount * $factor);
397 397
         $new_decimal = $v - $amount;
398 398
 
399
-        $new_hex_component = dechex( $new_decimal );
400
-        if ( strlen( $new_hex_component ) < 2 ) {
399
+        $new_hex_component = dechex($new_decimal);
400
+        if (strlen($new_hex_component) < 2) {
401 401
             $new_hex_component = "0" . $new_hex_component;
402 402
         }
403 403
         $color .= $new_hex_component;
@@ -406,18 +406,18 @@  discard block
 block discarded – undo
406 406
     return $color;
407 407
 }
408 408
 
409
-function wpinv_hex_lighter( $color, $factor = 30 ) {
410
-    $base  = wpinv_rgb_from_hex( $color );
409
+function wpinv_hex_lighter($color, $factor = 30) {
410
+    $base  = wpinv_rgb_from_hex($color);
411 411
     $color = '#';
412 412
 
413
-    foreach ( $base as $k => $v ) {
413
+    foreach ($base as $k => $v) {
414 414
         $amount      = 255 - $v;
415 415
         $amount      = $amount / 100;
416
-        $amount      = round( $amount * $factor );
416
+        $amount      = round($amount * $factor);
417 417
         $new_decimal = $v + $amount;
418 418
 
419
-        $new_hex_component = dechex( $new_decimal );
420
-        if ( strlen( $new_hex_component ) < 2 ) {
419
+        $new_hex_component = dechex($new_decimal);
420
+        if (strlen($new_hex_component) < 2) {
421 421
             $new_hex_component = "0" . $new_hex_component;
422 422
         }
423 423
         $color .= $new_hex_component;
@@ -426,22 +426,22 @@  discard block
 block discarded – undo
426 426
     return $color;
427 427
 }
428 428
 
429
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
430
-    $hex = str_replace( '#', '', $color );
429
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
430
+    $hex = str_replace('#', '', $color);
431 431
 
432
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
433
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
434
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
432
+    $c_r = hexdec(substr($hex, 0, 2));
433
+    $c_g = hexdec(substr($hex, 2, 2));
434
+    $c_b = hexdec(substr($hex, 4, 2));
435 435
 
436
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
436
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
437 437
 
438 438
     return $brightness > 155 ? $dark : $light;
439 439
 }
440 440
 
441
-function wpinv_format_hex( $hex ) {
442
-    $hex = trim( str_replace( '#', '', $hex ) );
441
+function wpinv_format_hex($hex) {
442
+    $hex = trim(str_replace('#', '', $hex));
443 443
 
444
-    if ( strlen( $hex ) == 3 ) {
444
+    if (strlen($hex) == 3) {
445 445
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
446 446
     }
447 447
 
@@ -461,12 +461,12 @@  discard block
 block discarded – undo
461 461
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
462 462
  * @return string
463 463
  */
464
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
465
-    if ( function_exists( 'mb_strimwidth' ) ) {
466
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
464
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
465
+    if (function_exists('mb_strimwidth')) {
466
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
467 467
     }
468 468
     
469
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
469
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
470 470
 }
471 471
 
472 472
 /**
@@ -478,28 +478,28 @@  discard block
 block discarded – undo
478 478
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
479 479
  * @return int Returns the number of characters in string.
480 480
  */
481
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
482
-    if ( function_exists( 'mb_strlen' ) ) {
483
-        return mb_strlen( $str, $encoding );
481
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
482
+    if (function_exists('mb_strlen')) {
483
+        return mb_strlen($str, $encoding);
484 484
     }
485 485
         
486
-    return strlen( $str );
486
+    return strlen($str);
487 487
 }
488 488
 
489
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
490
-    if ( function_exists( 'mb_strtolower' ) ) {
491
-        return mb_strtolower( $str, $encoding );
489
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
490
+    if (function_exists('mb_strtolower')) {
491
+        return mb_strtolower($str, $encoding);
492 492
     }
493 493
     
494
-    return strtolower( $str );
494
+    return strtolower($str);
495 495
 }
496 496
 
497
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
498
-    if ( function_exists( 'mb_strtoupper' ) ) {
499
-        return mb_strtoupper( $str, $encoding );
497
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
498
+    if (function_exists('mb_strtoupper')) {
499
+        return mb_strtoupper($str, $encoding);
500 500
     }
501 501
     
502
-    return strtoupper( $str );
502
+    return strtoupper($str);
503 503
 }
504 504
 
505 505
 /**
@@ -513,12 +513,12 @@  discard block
 block discarded – undo
513 513
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
514 514
  * @return int Returns the position of the first occurrence of search in the string.
515 515
  */
516
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
517
-    if ( function_exists( 'mb_strpos' ) ) {
518
-        return mb_strpos( $str, $find, $offset, $encoding );
516
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
517
+    if (function_exists('mb_strpos')) {
518
+        return mb_strpos($str, $find, $offset, $encoding);
519 519
     }
520 520
         
521
-    return strpos( $str, $find, $offset );
521
+    return strpos($str, $find, $offset);
522 522
 }
523 523
 
524 524
 /**
@@ -532,12 +532,12 @@  discard block
 block discarded – undo
532 532
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
533 533
  * @return int Returns the position of the last occurrence of search.
534 534
  */
535
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
536
-    if ( function_exists( 'mb_strrpos' ) ) {
537
-        return mb_strrpos( $str, $find, $offset, $encoding );
535
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
536
+    if (function_exists('mb_strrpos')) {
537
+        return mb_strrpos($str, $find, $offset, $encoding);
538 538
     }
539 539
         
540
-    return strrpos( $str, $find, $offset );
540
+    return strrpos($str, $find, $offset);
541 541
 }
542 542
 
543 543
 /**
@@ -552,16 +552,16 @@  discard block
 block discarded – undo
552 552
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
553 553
  * @return string
554 554
  */
555
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
556
-    if ( function_exists( 'mb_substr' ) ) {
557
-        if ( $length === null ) {
558
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
555
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
556
+    if (function_exists('mb_substr')) {
557
+        if ($length === null) {
558
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
559 559
         } else {
560
-            return mb_substr( $str, $start, $length, $encoding );
560
+            return mb_substr($str, $start, $length, $encoding);
561 561
         }
562 562
     }
563 563
         
564
-    return substr( $str, $start, $length );
564
+    return substr($str, $start, $length);
565 565
 }
566 566
 
567 567
 /**
@@ -573,48 +573,48 @@  discard block
 block discarded – undo
573 573
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
574 574
  * @return string The width of string.
575 575
  */
576
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
577
-    if ( function_exists( 'mb_strwidth' ) ) {
578
-        return mb_strwidth( $str, $encoding );
576
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
577
+    if (function_exists('mb_strwidth')) {
578
+        return mb_strwidth($str, $encoding);
579 579
     }
580 580
     
581
-    return wpinv_utf8_strlen( $str, $encoding );
581
+    return wpinv_utf8_strlen($str, $encoding);
582 582
 }
583 583
 
584
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
585
-    if ( function_exists( 'mb_strlen' ) ) {
586
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
584
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
585
+    if (function_exists('mb_strlen')) {
586
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
587 587
         $str_end = "";
588 588
         
589
-        if ( $lower_str_end ) {
590
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
589
+        if ($lower_str_end) {
590
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
591 591
         } else {
592
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
592
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
593 593
         }
594 594
 
595 595
         return $first_letter . $str_end;
596 596
     }
597 597
     
598
-    return ucfirst( $str );
598
+    return ucfirst($str);
599 599
 }
600 600
 
601
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
602
-    if ( function_exists( 'mb_convert_case' ) ) {
603
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
601
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
602
+    if (function_exists('mb_convert_case')) {
603
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
604 604
     }
605 605
     
606
-    return ucwords( $str );
606
+    return ucwords($str);
607 607
 }
608 608
 
609
-function wpinv_period_in_days( $period, $unit ) {
610
-    $period = absint( $period );
609
+function wpinv_period_in_days($period, $unit) {
610
+    $period = absint($period);
611 611
     
612
-    if ( $period > 0 ) {
613
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
612
+    if ($period > 0) {
613
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
614 614
             $period = $period * 7;
615
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
615
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
616 616
             $period = $period * 30;
617
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
617
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
618 618
             $period = $period * 365;
619 619
         }
620 620
     }
@@ -622,14 +622,14 @@  discard block
 block discarded – undo
622 622
     return $period;
623 623
 }
624 624
 
625
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
626
-    if ( function_exists( 'cal_days_in_month' ) ) {
627
-        return cal_days_in_month( $calendar, $month, $year );
625
+function wpinv_cal_days_in_month($calendar, $month, $year) {
626
+    if (function_exists('cal_days_in_month')) {
627
+        return cal_days_in_month($calendar, $month, $year);
628 628
     }
629 629
 
630 630
     // Fallback in case the calendar extension is not loaded in PHP
631 631
     // Only supports Gregorian calendar
632
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
632
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
633 633
 }
634 634
 
635 635
 /**
@@ -640,12 +640,12 @@  discard block
 block discarded – undo
640 640
  *
641 641
  * @return string
642 642
  */
643
-function wpi_help_tip( $tip, $allow_html = false ) {
643
+function wpi_help_tip($tip, $allow_html = false) {
644 644
 
645
-    if ( $allow_html ) {
646
-        $tip = wpi_sanitize_tooltip( $tip );
645
+    if ($allow_html) {
646
+        $tip = wpi_sanitize_tooltip($tip);
647 647
     } else {
648
-        $tip = esc_attr( $tip );
648
+        $tip = esc_attr($tip);
649 649
     }
650 650
 
651 651
     return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -659,8 +659,8 @@  discard block
 block discarded – undo
659 659
  * @param string $var
660 660
  * @return string
661 661
  */
662
-function wpi_sanitize_tooltip( $var ) {
663
-    return wp_kses( html_entity_decode( $var ), array(
662
+function wpi_sanitize_tooltip($var) {
663
+    return wp_kses(html_entity_decode($var), array(
664 664
         'br'     => array(),
665 665
         'em'     => array(),
666 666
         'strong' => array(),
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
         'li'     => array(),
672 672
         'ol'     => array(),
673 673
         'p'      => array(),
674
-    ) );
674
+    ));
675 675
 }
676 676
 
677 677
 /**
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
  */
682 682
 function wpinv_get_screen_ids() {
683 683
 
684
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
684
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
685 685
 
686 686
     $screen_ids = array(
687 687
         'toplevel_page_' . $screen_id,
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
         'invoicing_page_wpi-addons',
700 700
     );
701 701
 
702
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
702
+    return apply_filters('wpinv_screen_ids', $screen_ids);
703 703
 }
704 704
 
705 705
 /**
@@ -710,14 +710,14 @@  discard block
 block discarded – undo
710 710
  * @param array|string $list List of values.
711 711
  * @return array Sanitized array of values.
712 712
  */
713
-function wpinv_parse_list( $list ) {
713
+function wpinv_parse_list($list) {
714 714
 
715
-    if ( empty( $list ) ) {
715
+    if (empty($list)) {
716 716
         $list = array();
717 717
     }
718 718
 
719
-	if ( ! is_array( $list ) ) {
720
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
719
+	if (!is_array($list)) {
720
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
721 721
 	}
722 722
 
723 723
 	return $list;
@@ -731,16 +731,16 @@  discard block
 block discarded – undo
731 731
  * @param string $key Type of data to fetch.
732 732
  * @return mixed Fetched data.
733 733
  */
734
-function wpinv_get_data( $key ) {
734
+function wpinv_get_data($key) {
735 735
 
736 736
     // Try fetching it from the cache.
737
-    $data = wp_cache_get( "wpinv-data-$key", 'wpinv' );
738
-    if( $data ) {
737
+    $data = wp_cache_get("wpinv-data-$key", 'wpinv');
738
+    if ($data) {
739 739
         return $data;
740 740
     }
741 741
 
742
-    $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
743
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
742
+    $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
743
+	wp_cache_set("wpinv-data-$key", $data, 'wpinv');
744 744
 
745 745
 	return $data;
746 746
 }
@@ -754,10 +754,10 @@  discard block
 block discarded – undo
754 754
  * @param bool $first_empty Whether or not the first item in the list should be empty
755 755
  * @return mixed Fetched data.
756 756
  */
757
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
757
+function wpinv_maybe_add_empty_option($options, $first_empty) {
758 758
 
759
-    if ( ! empty( $options ) && $first_empty ) {
760
-        return array_merge( array( '' => '' ), $options );
759
+    if (!empty($options) && $first_empty) {
760
+        return array_merge(array('' => ''), $options);
761 761
     }
762 762
     return $options;
763 763
 
@@ -769,21 +769,21 @@  discard block
 block discarded – undo
769 769
  * @param mixed $var Data to sanitize.
770 770
  * @return string|array
771 771
  */
772
-function wpinv_clean( $var ) {
772
+function wpinv_clean($var) {
773 773
 
774
-	if ( is_array( $var ) ) {
775
-		return array_map( 'wpinv_clean', $var );
774
+	if (is_array($var)) {
775
+		return array_map('wpinv_clean', $var);
776 776
     }
777 777
 
778
-    if ( is_object( $var ) ) {
779
-		$object_vars = get_object_vars( $var );
780
-		foreach ( $object_vars as $property_name => $property_value ) {
781
-			$var->$property_name = wpinv_clean( $property_value );
778
+    if (is_object($var)) {
779
+		$object_vars = get_object_vars($var);
780
+		foreach ($object_vars as $property_name => $property_value) {
781
+			$var->$property_name = wpinv_clean($property_value);
782 782
         }
783 783
         return $var;
784 784
 	}
785 785
     
786
-    return is_string( $var ) ? sanitize_text_field( $var ) : $var;
786
+    return is_string($var) ? sanitize_text_field($var) : $var;
787 787
 }
788 788
 
789 789
 /**
@@ -792,43 +792,43 @@  discard block
 block discarded – undo
792 792
  * @param string $str Data to convert.
793 793
  * @return string|array
794 794
  */
795
-function getpaid_convert_price_string_to_options( $str ) {
795
+function getpaid_convert_price_string_to_options($str) {
796 796
 
797
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
798
-    $options     = array();
797
+	$raw_options = array_map('trim', explode(',', $str));
798
+    $options = array();
799 799
 
800
-    foreach ( $raw_options as $option ) {
800
+    foreach ($raw_options as $option) {
801 801
 
802
-        if ( '' == $option ) {
802
+        if ('' == $option) {
803 803
             continue;
804 804
         }
805 805
 
806
-        $option = array_map( 'trim', explode( '|', $option ) );
806
+        $option = array_map('trim', explode('|', $option));
807 807
 
808 808
         $price = null;
809 809
         $label = null;
810 810
 
811
-        if ( isset( $option[0] ) && '' !=  $option[0] ) {
812
-            $label  = $option[0];
811
+        if (isset($option[0]) && '' != $option[0]) {
812
+            $label = $option[0];
813 813
         }
814 814
 
815
-        if ( isset( $option[1] ) && '' !=  $option[1] ) {
815
+        if (isset($option[1]) && '' != $option[1]) {
816 816
             $price = $option[1];
817 817
         }
818 818
 
819
-        if ( ! isset( $price ) ) {
819
+        if (!isset($price)) {
820 820
             $price = $label;
821 821
         }
822 822
 
823
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
823
+        if (!isset($price) || !is_numeric($price)) {
824 824
             continue;
825 825
         }
826 826
 
827
-        if ( ! isset( $label ) ) {
827
+        if (!isset($label)) {
828 828
             $label = $price;
829 829
         }
830 830
 
831
-        $options[ $price ] = $label;
831
+        $options[$price] = $label;
832 832
     }
833 833
 
834 834
     return $options;
@@ -837,22 +837,22 @@  discard block
 block discarded – undo
837 837
 /**
838 838
  * Returns the help tip.
839 839
  */
840
-function getpaid_get_help_tip( $tip, $additional_classes = '' ) {
841
-    $additional_classes = sanitize_html_class( $additional_classes );
842
-    $tip                = esc_attr__( $tip );
840
+function getpaid_get_help_tip($tip, $additional_classes = '') {
841
+    $additional_classes = sanitize_html_class($additional_classes);
842
+    $tip                = esc_attr__($tip);
843 843
     return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>";
844 844
 }
845 845
 
846 846
 /**
847 847
  * Formats a date
848 848
  */
849
-function getpaid_format_date( $date ) {
849
+function getpaid_format_date($date) {
850 850
 
851
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
851
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
852 852
         return '';
853 853
     }
854 854
 
855
-    return date_i18n( getpaid_date_format(), strtotime( $date ) );
855
+    return date_i18n(getpaid_date_format(), strtotime($date));
856 856
 
857 857
 }
858 858
 
@@ -861,9 +861,9 @@  discard block
 block discarded – undo
861 861
  *
862 862
  * @return string
863 863
  */
864
-function getpaid_format_date_value( $date, $default = "&mdash;" ) {
865
-    $date = getpaid_format_date( $date );
866
-    return empty( $date ) ? $default : $date;
864
+function getpaid_format_date_value($date, $default = "&mdash;") {
865
+    $date = getpaid_format_date($date);
866
+    return empty($date) ? $default : $date;
867 867
 }
868 868
 
869 869
 /**
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
  * @return string
873 873
  */
874 874
 function getpaid_date_format() {
875
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
875
+	return apply_filters('getpaid_date_format', get_option('date_format'));
876 876
 }
877 877
 
878 878
 /**
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
  * @return string
882 882
  */
883 883
 function getpaid_time_format() {
884
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
884
+	return apply_filters('getpaid_time_format', get_option('time_format'));
885 885
 }
886 886
 
887 887
 /**
@@ -891,16 +891,16 @@  discard block
 block discarded – undo
891 891
  * @param  integer $limit Limit size in characters.
892 892
  * @return string
893 893
  */
894
-function getpaid_limit_length( $string, $limit ) {
894
+function getpaid_limit_length($string, $limit) {
895 895
     $str_limit = $limit - 3;
896 896
 
897
-	if ( function_exists( 'mb_strimwidth' ) ) {
898
-		if ( mb_strlen( $string ) > $limit ) {
899
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
897
+	if (function_exists('mb_strimwidth')) {
898
+		if (mb_strlen($string) > $limit) {
899
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
900 900
 		}
901 901
 	} else {
902
-		if ( strlen( $string ) > $limit ) {
903
-			$string = substr( $string, 0, $str_limit ) . '...';
902
+		if (strlen($string) > $limit) {
903
+			$string = substr($string, 0, $str_limit) . '...';
904 904
 		}
905 905
 	}
906 906
     return $string;
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
  * @since 1.0.19
915 915
  */
916 916
 function getpaid_api() {
917
-    return getpaid()->get( 'api' );
917
+    return getpaid()->get('api');
918 918
 }
919 919
 
920 920
 /**
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
  * @since 1.0.19
925 925
  */
926 926
 function getpaid_post_types() {
927
-    return getpaid()->get( 'post_types' );
927
+    return getpaid()->get('post_types');
928 928
 }
929 929
 
930 930
 /**
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
  * @since 1.0.19
935 935
  */
936 936
 function getpaid_session() {
937
-    return getpaid()->get( 'session' );
937
+    return getpaid()->get('session');
938 938
 }
939 939
 
940 940
 /**
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
  * @since 1.0.19
945 945
  */
946 946
 function getpaid_notes() {
947
-    return getpaid()->get( 'notes' );
947
+    return getpaid()->get('notes');
948 948
 }
949 949
 
950 950
 /**
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
  * @return GetPaid_Admin
954 954
  */
955 955
 function getpaid_admin() {
956
-    return getpaid()->get( 'admin' );
956
+    return getpaid()->get('admin');
957 957
 }
958 958
 
959 959
 /**
@@ -963,8 +963,8 @@  discard block
 block discarded – undo
963 963
  * @param string $base the base url
964 964
  * @return string
965 965
  */
966
-function getpaid_get_authenticated_action_url( $action, $base = false ) {
967
-    return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' );
966
+function getpaid_get_authenticated_action_url($action, $base = false) {
967
+    return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce');
968 968
 }
969 969
 
970 970
 /**
@@ -972,11 +972,11 @@  discard block
 block discarded – undo
972 972
  *
973 973
  * @return string
974 974
  */
975
-function getpaid_get_post_type_label( $post_type, $plural = true ) {
975
+function getpaid_get_post_type_label($post_type, $plural = true) {
976 976
 
977
-    $post_type = get_post_type_object( $post_type );
977
+    $post_type = get_post_type_object($post_type);
978 978
 
979
-    if ( ! is_object( $post_type ) ) {
979
+    if (!is_object($post_type)) {
980 980
         return null;
981 981
     }
982 982
 
@@ -989,18 +989,18 @@  discard block
 block discarded – undo
989 989
  *
990 990
  * @return mixed|null
991 991
  */
992
-function getpaid_get_array_field( $array, $key, $secondary_key = null ) {
992
+function getpaid_get_array_field($array, $key, $secondary_key = null) {
993 993
 
994
-    if ( ! is_array( $array ) ) {
994
+    if (!is_array($array)) {
995 995
         return null;
996 996
     }
997 997
 
998
-    if ( ! empty( $secondary_key ) ) {
999
-        $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array();
1000
-        return getpaid_get_array_field( $array, $key );
998
+    if (!empty($secondary_key)) {
999
+        $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array();
1000
+        return getpaid_get_array_field($array, $key);
1001 1001
     }
1002 1002
 
1003
-    return isset( $array[ $key ] ) ? $array[ $key ] : null;
1003
+    return isset($array[$key]) ? $array[$key] : null;
1004 1004
 
1005 1005
 }
1006 1006
 
@@ -1009,12 +1009,12 @@  discard block
 block discarded – undo
1009 1009
  *
1010 1010
  * @return array
1011 1011
  */
1012
-function getpaid_array_merge_if_empty( $args, $defaults ) {
1012
+function getpaid_array_merge_if_empty($args, $defaults) {
1013 1013
 
1014
-    foreach ( $defaults as $key => $value ) {
1014
+    foreach ($defaults as $key => $value) {
1015 1015
 
1016
-        if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) {
1017
-            $args[ $key ] = $value;
1016
+        if (array_key_exists($key, $args) && empty($args[$key])) {
1017
+            $args[$key] = $value;
1018 1018
         }
1019 1019
 
1020 1020
     }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-refresh-prices.php 2 patches
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -12,224 +12,224 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Refresh_Prices {
14 14
 
15
-	/**
16
-	 * Contains the response for refreshing prices.
17
-	 * @var array
18
-	 */
19
-	public $response = array();
15
+    /**
16
+     * Contains the response for refreshing prices.
17
+     * @var array
18
+     */
19
+    public $response = array();
20 20
 
21 21
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
27
-
28
-		$this->response = array(
29
-			'submission_id' => $submission->id,
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27
+
28
+        $this->response = array(
29
+            'submission_id' => $submission->id,
30 30
             'has_recurring' => $submission->has_recurring,
31 31
             'is_free'       => ! $submission->should_collect_payment_details(),
32
-		);
33
-
34
-		$this->add_totals( $submission );
35
-		$this->add_texts( $submission );
36
-		$this->add_items( $submission );
37
-		$this->add_fees( $submission );
38
-		$this->add_discounts( $submission );
39
-		$this->add_taxes( $submission );
40
-		$this->add_gateways( $submission );
41
-
42
-	}
43
-
44
-	/**
45
-	 * Adds totals to a response for submission refresh prices.
46
-	 *
47
-	 * @param GetPaid_Payment_Form_Submission $submission
48
-	 */
49
-	public function add_totals( $submission ) {
50
-
51
-		$this->response = array_merge(
52
-			$this->response,
53
-			array(
54
-
55
-				'totals'        => array(
56
-					'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
57
-					'discount'  => $submission->format_amount( $submission->get_discount() ),
58
-					'fees'      => $submission->format_amount( $submission->get_fee() ),
59
-					'tax'       => $submission->format_amount( $submission->get_tax() ),
60
-					'total'     => $submission->format_amount( $submission->get_total() ),
61
-					'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
62
-				),
63
-
64
-				'recurring'     => array(
65
-					'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
66
-					'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
67
-					'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
68
-					'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
69
-					'total'     => $submission->format_amount( $submission->get_recurring_total() ),
70
-				),
71
-
72
-			)
73
-		);
74
-
75
-	}
76
-
77
-	/**
78
-	 * Adds texts to a response for submission refresh prices.
79
-	 *
80
-	 * @param GetPaid_Payment_Form_Submission $submission
81
-	 */
82
-	public function add_texts( $submission ) {
83
-
84
-		$payable = $submission->format_amount( $submission->get_total() );
85
-
86
-		if ( $submission->has_recurring != 0 ) {
87
-
88
-			$recurring = new WPInv_Item( $submission->has_recurring );
89
-			$period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
90
-
91
-			if ( $submission->get_total() == $submission->get_recurring_total() ) {
92
-				$payable = "$payable / $period";
93
-			} else {
94
-				$payable = sprintf(
95
-					__( '%1$s (renews at %2$s / %3$s)'),
96
-					$submission->format_amount( $submission->get_total() ),
97
-					$submission->format_amount( $submission->get_recurring_total() ),
98
-					$period
99
-				);
100
-			}
101
-
102
-		}
103
-
104
-		$texts = array(
105
-			'.getpaid-checkout-total-payable' => $payable,
106
-		);
107
-
108
-		foreach ( $submission->get_items() as $item_id => $item ) {
109
-			$texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount( $item->get_sub_total() );
110
-			$texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() );
111
-		}
112
-
113
-		$this->response = array_merge( $this->response, array( 'texts' => $texts ) );
114
-
115
-	}
116
-
117
-	/**
118
-	 * Adds items to a response for submission refresh prices.
119
-	 *
120
-	 * @param GetPaid_Payment_Form_Submission $submission
121
-	 */
122
-	public function add_items( $submission ) {
123
-
124
-		// Add items.
125
-		$items = array();
32
+        );
33
+
34
+        $this->add_totals( $submission );
35
+        $this->add_texts( $submission );
36
+        $this->add_items( $submission );
37
+        $this->add_fees( $submission );
38
+        $this->add_discounts( $submission );
39
+        $this->add_taxes( $submission );
40
+        $this->add_gateways( $submission );
41
+
42
+    }
43
+
44
+    /**
45
+     * Adds totals to a response for submission refresh prices.
46
+     *
47
+     * @param GetPaid_Payment_Form_Submission $submission
48
+     */
49
+    public function add_totals( $submission ) {
50
+
51
+        $this->response = array_merge(
52
+            $this->response,
53
+            array(
54
+
55
+                'totals'        => array(
56
+                    'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
57
+                    'discount'  => $submission->format_amount( $submission->get_discount() ),
58
+                    'fees'      => $submission->format_amount( $submission->get_fee() ),
59
+                    'tax'       => $submission->format_amount( $submission->get_tax() ),
60
+                    'total'     => $submission->format_amount( $submission->get_total() ),
61
+                    'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
62
+                ),
63
+
64
+                'recurring'     => array(
65
+                    'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
66
+                    'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
67
+                    'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
68
+                    'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
69
+                    'total'     => $submission->format_amount( $submission->get_recurring_total() ),
70
+                ),
71
+
72
+            )
73
+        );
74
+
75
+    }
76
+
77
+    /**
78
+     * Adds texts to a response for submission refresh prices.
79
+     *
80
+     * @param GetPaid_Payment_Form_Submission $submission
81
+     */
82
+    public function add_texts( $submission ) {
83
+
84
+        $payable = $submission->format_amount( $submission->get_total() );
85
+
86
+        if ( $submission->has_recurring != 0 ) {
87
+
88
+            $recurring = new WPInv_Item( $submission->has_recurring );
89
+            $period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
90
+
91
+            if ( $submission->get_total() == $submission->get_recurring_total() ) {
92
+                $payable = "$payable / $period";
93
+            } else {
94
+                $payable = sprintf(
95
+                    __( '%1$s (renews at %2$s / %3$s)'),
96
+                    $submission->format_amount( $submission->get_total() ),
97
+                    $submission->format_amount( $submission->get_recurring_total() ),
98
+                    $period
99
+                );
100
+            }
101
+
102
+        }
103
+
104
+        $texts = array(
105
+            '.getpaid-checkout-total-payable' => $payable,
106
+        );
126 107
 
127 108
         foreach ( $submission->get_items() as $item_id => $item ) {
128
-			$items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
129
-		}
109
+            $texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount( $item->get_sub_total() );
110
+            $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() );
111
+        }
130 112
 
131
-		$this->response = array_merge(
132
-			$this->response,
133
-			array( 'items' => $items )
134
-		);
113
+        $this->response = array_merge( $this->response, array( 'texts' => $texts ) );
135 114
 
136
-	}
115
+    }
137 116
 
138
-	/**
139
-	 * Adds fees to a response for submission refresh prices.
140
-	 *
141
-	 * @param GetPaid_Payment_Form_Submission $submission
142
-	 */
143
-	public function add_fees( $submission ) {
117
+    /**
118
+     * Adds items to a response for submission refresh prices.
119
+     *
120
+     * @param GetPaid_Payment_Form_Submission $submission
121
+     */
122
+    public function add_items( $submission ) {
123
+
124
+        // Add items.
125
+        $items = array();
126
+
127
+        foreach ( $submission->get_items() as $item_id => $item ) {
128
+            $items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
129
+        }
130
+
131
+        $this->response = array_merge(
132
+            $this->response,
133
+            array( 'items' => $items )
134
+        );
135
+
136
+    }
144 137
 
145
-		$fees = array();
138
+    /**
139
+     * Adds fees to a response for submission refresh prices.
140
+     *
141
+     * @param GetPaid_Payment_Form_Submission $submission
142
+     */
143
+    public function add_fees( $submission ) {
144
+
145
+        $fees = array();
146 146
 
147 147
         foreach ( $submission->get_fees() as $name => $data ) {
148
-			$fees[$name] = $submission->format_amount( $data['initial_fee'] );
149
-		}
148
+            $fees[$name] = $submission->format_amount( $data['initial_fee'] );
149
+        }
150 150
 
151
-		$this->response = array_merge(
152
-			$this->response,
153
-			array( 'fees' => $fees )
154
-		);
151
+        $this->response = array_merge(
152
+            $this->response,
153
+            array( 'fees' => $fees )
154
+        );
155 155
 
156
-	}
156
+    }
157 157
 
158
-	/**
159
-	 * Adds discounts to a response for submission refresh prices.
160
-	 *
161
-	 * @param GetPaid_Payment_Form_Submission $submission
162
-	 */
163
-	public function add_discounts( $submission ) {
158
+    /**
159
+     * Adds discounts to a response for submission refresh prices.
160
+     *
161
+     * @param GetPaid_Payment_Form_Submission $submission
162
+     */
163
+    public function add_discounts( $submission ) {
164 164
 
165
-		$discounts = array();
165
+        $discounts = array();
166 166
 
167 167
         foreach ( $submission->get_discounts() as $name => $data ) {
168
-			$discounts[$name] = $submission->format_amount( $data['initial_discount'] );
169
-		}
168
+            $discounts[$name] = $submission->format_amount( $data['initial_discount'] );
169
+        }
170 170
 
171
-		$this->response = array_merge(
172
-			$this->response,
173
-			array( 'discounts' => $discounts )
174
-		);
171
+        $this->response = array_merge(
172
+            $this->response,
173
+            array( 'discounts' => $discounts )
174
+        );
175 175
 
176
-	}
176
+    }
177 177
 
178
-	/**
179
-	 * Adds taxes to a response for submission refresh prices.
180
-	 *
181
-	 * @param GetPaid_Payment_Form_Submission $submission
182
-	 */
183
-	public function add_taxes( $submission ) {
184
-
185
-		$taxes  = array();
186
-		$markup = '';
178
+    /**
179
+     * Adds taxes to a response for submission refresh prices.
180
+     *
181
+     * @param GetPaid_Payment_Form_Submission $submission
182
+     */
183
+    public function add_taxes( $submission ) {
184
+
185
+        $taxes  = array();
186
+        $markup = '';
187 187
         foreach ( $submission->get_taxes() as $name => $data ) {
188
-			$name          = sanitize_text_field( $name );
189
-			$amount        = $submission->format_amount( $data['initial_tax'] );
190
-			$taxes[$name]  = $amount;
191
-			$markup       .= "<small class='form-text'>$name : $amount</small>";
192
-		}
188
+            $name          = sanitize_text_field( $name );
189
+            $amount        = $submission->format_amount( $data['initial_tax'] );
190
+            $taxes[$name]  = $amount;
191
+            $markup       .= "<small class='form-text'>$name : $amount</small>";
192
+        }
193 193
 
194
-		if ( wpinv_display_individual_tax_rates() ) {
195
-			$this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup;
196
-		}
194
+        if ( wpinv_display_individual_tax_rates() ) {
195
+            $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup;
196
+        }
197 197
 
198
-		$this->response = array_merge(
199
-			$this->response,
200
-			array( 'taxes' => $taxes )
201
-		);
198
+        $this->response = array_merge(
199
+            $this->response,
200
+            array( 'taxes' => $taxes )
201
+        );
202 202
 
203
-	}
203
+    }
204 204
 
205
-	/**
206
-	 * Adds gateways to a response for submission refresh prices.
207
-	 *
208
-	 * @param GetPaid_Payment_Form_Submission $submission
209
-	 */
210
-	public function add_gateways( $submission ) {
205
+    /**
206
+     * Adds gateways to a response for submission refresh prices.
207
+     *
208
+     * @param GetPaid_Payment_Form_Submission $submission
209
+     */
210
+    public function add_gateways( $submission ) {
211 211
 
212
-		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
212
+        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
213 213
 
214
-		if ( $this->response['has_recurring'] ) {
214
+        if ( $this->response['has_recurring'] ) {
215 215
 
216
-			foreach ( $gateways as $i => $gateway ) {
216
+            foreach ( $gateways as $i => $gateway ) {
217 217
 
218
-				if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
219
-					unset( $gateways[ $i ] );
220
-				}
218
+                if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
219
+                    unset( $gateways[ $i ] );
220
+                }
221 221
 
222
-			}
222
+            }
223 223
 
224
-		}
224
+        }
225 225
 
226 226
 
227
-		$gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
228
-		$this->response = array_merge(
229
-			$this->response,
230
-			array( 'gateways' => $gateways )
231
-		);
227
+        $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
228
+        $this->response = array_merge(
229
+            $this->response,
230
+            array( 'gateways' => $gateways )
231
+        );
232 232
 
233
-	}
233
+    }
234 234
 
235 235
 }
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission refresh prices class
@@ -23,21 +23,21 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param GetPaid_Payment_Form_Submission $submission
25 25
 	 */
26
-	public function __construct( $submission ) {
26
+	public function __construct($submission) {
27 27
 
28 28
 		$this->response = array(
29 29
 			'submission_id' => $submission->id,
30 30
             'has_recurring' => $submission->has_recurring,
31
-            'is_free'       => ! $submission->should_collect_payment_details(),
31
+            'is_free'       => !$submission->should_collect_payment_details(),
32 32
 		);
33 33
 
34
-		$this->add_totals( $submission );
35
-		$this->add_texts( $submission );
36
-		$this->add_items( $submission );
37
-		$this->add_fees( $submission );
38
-		$this->add_discounts( $submission );
39
-		$this->add_taxes( $submission );
40
-		$this->add_gateways( $submission );
34
+		$this->add_totals($submission);
35
+		$this->add_texts($submission);
36
+		$this->add_items($submission);
37
+		$this->add_fees($submission);
38
+		$this->add_discounts($submission);
39
+		$this->add_taxes($submission);
40
+		$this->add_gateways($submission);
41 41
 
42 42
 	}
43 43
 
@@ -46,27 +46,27 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @param GetPaid_Payment_Form_Submission $submission
48 48
 	 */
49
-	public function add_totals( $submission ) {
49
+	public function add_totals($submission) {
50 50
 
51 51
 		$this->response = array_merge(
52 52
 			$this->response,
53 53
 			array(
54 54
 
55 55
 				'totals'        => array(
56
-					'subtotal'  => $submission->format_amount( $submission->get_subtotal() ),
57
-					'discount'  => $submission->format_amount( $submission->get_discount() ),
58
-					'fees'      => $submission->format_amount( $submission->get_fee() ),
59
-					'tax'       => $submission->format_amount( $submission->get_tax() ),
60
-					'total'     => $submission->format_amount( $submission->get_total() ),
61
-					'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ),
56
+					'subtotal'  => $submission->format_amount($submission->get_subtotal()),
57
+					'discount'  => $submission->format_amount($submission->get_discount()),
58
+					'fees'      => $submission->format_amount($submission->get_fee()),
59
+					'tax'       => $submission->format_amount($submission->get_tax()),
60
+					'total'     => $submission->format_amount($submission->get_total()),
61
+					'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES),
62 62
 				),
63 63
 
64 64
 				'recurring'     => array(
65
-					'subtotal'  => $submission->format_amount( $submission->get_recurring_subtotal() ),
66
-					'discount'  => $submission->format_amount( $submission->get_recurring_discount() ),
67
-					'fees'      => $submission->format_amount( $submission->get_recurring_fee() ),
68
-					'tax'       => $submission->format_amount( $submission->get_recurring_tax() ),
69
-					'total'     => $submission->format_amount( $submission->get_recurring_total() ),
65
+					'subtotal'  => $submission->format_amount($submission->get_recurring_subtotal()),
66
+					'discount'  => $submission->format_amount($submission->get_recurring_discount()),
67
+					'fees'      => $submission->format_amount($submission->get_recurring_fee()),
68
+					'tax'       => $submission->format_amount($submission->get_recurring_tax()),
69
+					'total'     => $submission->format_amount($submission->get_recurring_total()),
70 70
 				),
71 71
 
72 72
 			)
@@ -79,22 +79,22 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param GetPaid_Payment_Form_Submission $submission
81 81
 	 */
82
-	public function add_texts( $submission ) {
82
+	public function add_texts($submission) {
83 83
 
84
-		$payable = $submission->format_amount( $submission->get_total() );
84
+		$payable = $submission->format_amount($submission->get_total());
85 85
 
86
-		if ( $submission->has_recurring != 0 ) {
86
+		if ($submission->has_recurring != 0) {
87 87
 
88
-			$recurring = new WPInv_Item( $submission->has_recurring );
89
-			$period    = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' );
88
+			$recurring = new WPInv_Item($submission->has_recurring);
89
+			$period    = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), '');
90 90
 
91
-			if ( $submission->get_total() == $submission->get_recurring_total() ) {
91
+			if ($submission->get_total() == $submission->get_recurring_total()) {
92 92
 				$payable = "$payable / $period";
93 93
 			} else {
94 94
 				$payable = sprintf(
95
-					__( '%1$s (renews at %2$s / %3$s)'),
96
-					$submission->format_amount( $submission->get_total() ),
97
-					$submission->format_amount( $submission->get_recurring_total() ),
95
+					__('%1$s (renews at %2$s / %3$s)'),
96
+					$submission->format_amount($submission->get_total()),
97
+					$submission->format_amount($submission->get_recurring_total()),
98 98
 					$period
99 99
 				);
100 100
 			}
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 			'.getpaid-checkout-total-payable' => $payable,
106 106
 		);
107 107
 
108
-		foreach ( $submission->get_items() as $item_id => $item ) {
109
-			$texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount( $item->get_sub_total() );
110
-			$texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() );
108
+		foreach ($submission->get_items() as $item_id => $item) {
109
+			$texts[".item-$item_id .getpaid-item-initial-price"]   = $submission->format_amount($item->get_sub_total());
110
+			$texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount($item->get_recurring_sub_total());
111 111
 		}
112 112
 
113
-		$this->response = array_merge( $this->response, array( 'texts' => $texts ) );
113
+		$this->response = array_merge($this->response, array('texts' => $texts));
114 114
 
115 115
 	}
116 116
 
@@ -119,18 +119,18 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @param GetPaid_Payment_Form_Submission $submission
121 121
 	 */
122
-	public function add_items( $submission ) {
122
+	public function add_items($submission) {
123 123
 
124 124
 		// Add items.
125 125
 		$items = array();
126 126
 
127
-        foreach ( $submission->get_items() as $item_id => $item ) {
128
-			$items["$item_id"] = $submission->format_amount( $item->get_sub_total() );
127
+        foreach ($submission->get_items() as $item_id => $item) {
128
+			$items["$item_id"] = $submission->format_amount($item->get_sub_total());
129 129
 		}
130 130
 
131 131
 		$this->response = array_merge(
132 132
 			$this->response,
133
-			array( 'items' => $items )
133
+			array('items' => $items)
134 134
 		);
135 135
 
136 136
 	}
@@ -140,17 +140,17 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @param GetPaid_Payment_Form_Submission $submission
142 142
 	 */
143
-	public function add_fees( $submission ) {
143
+	public function add_fees($submission) {
144 144
 
145 145
 		$fees = array();
146 146
 
147
-        foreach ( $submission->get_fees() as $name => $data ) {
148
-			$fees[$name] = $submission->format_amount( $data['initial_fee'] );
147
+        foreach ($submission->get_fees() as $name => $data) {
148
+			$fees[$name] = $submission->format_amount($data['initial_fee']);
149 149
 		}
150 150
 
151 151
 		$this->response = array_merge(
152 152
 			$this->response,
153
-			array( 'fees' => $fees )
153
+			array('fees' => $fees)
154 154
 		);
155 155
 
156 156
 	}
@@ -160,17 +160,17 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @param GetPaid_Payment_Form_Submission $submission
162 162
 	 */
163
-	public function add_discounts( $submission ) {
163
+	public function add_discounts($submission) {
164 164
 
165 165
 		$discounts = array();
166 166
 
167
-        foreach ( $submission->get_discounts() as $name => $data ) {
168
-			$discounts[$name] = $submission->format_amount( $data['initial_discount'] );
167
+        foreach ($submission->get_discounts() as $name => $data) {
168
+			$discounts[$name] = $submission->format_amount($data['initial_discount']);
169 169
 		}
170 170
 
171 171
 		$this->response = array_merge(
172 172
 			$this->response,
173
-			array( 'discounts' => $discounts )
173
+			array('discounts' => $discounts)
174 174
 		);
175 175
 
176 176
 	}
@@ -180,24 +180,24 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @param GetPaid_Payment_Form_Submission $submission
182 182
 	 */
183
-	public function add_taxes( $submission ) {
183
+	public function add_taxes($submission) {
184 184
 
185 185
 		$taxes  = array();
186 186
 		$markup = '';
187
-        foreach ( $submission->get_taxes() as $name => $data ) {
188
-			$name          = sanitize_text_field( $name );
189
-			$amount        = $submission->format_amount( $data['initial_tax'] );
187
+        foreach ($submission->get_taxes() as $name => $data) {
188
+			$name          = sanitize_text_field($name);
189
+			$amount        = $submission->format_amount($data['initial_tax']);
190 190
 			$taxes[$name]  = $amount;
191 191
 			$markup       .= "<small class='form-text'>$name : $amount</small>";
192 192
 		}
193 193
 
194
-		if ( wpinv_display_individual_tax_rates() ) {
194
+		if (wpinv_display_individual_tax_rates()) {
195 195
 			$this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup;
196 196
 		}
197 197
 
198 198
 		$this->response = array_merge(
199 199
 			$this->response,
200
-			array( 'taxes' => $taxes )
200
+			array('taxes' => $taxes)
201 201
 		);
202 202
 
203 203
 	}
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @param GetPaid_Payment_Form_Submission $submission
209 209
 	 */
210
-	public function add_gateways( $submission ) {
210
+	public function add_gateways($submission) {
211 211
 
212
-		$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
212
+		$gateways = array_keys(wpinv_get_enabled_payment_gateways());
213 213
 
214
-		if ( $this->response['has_recurring'] ) {
214
+		if ($this->response['has_recurring']) {
215 215
 
216
-			foreach ( $gateways as $i => $gateway ) {
216
+			foreach ($gateways as $i => $gateway) {
217 217
 
218
-				if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
219
-					unset( $gateways[ $i ] );
218
+				if (!wpinv_gateway_support_subscription($gateway)) {
219
+					unset($gateways[$i]);
220 220
 				}
221 221
 
222 222
 			}
@@ -224,10 +224,10 @@  discard block
 block discarded – undo
224 224
 		}
225 225
 
226 226
 
227
-		$gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission );
227
+		$gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission);
228 228
 		$this->response = array_merge(
229 229
 			$this->response,
230
-			array( 'gateways' => $gateways )
230
+			array('gateways' => $gateways)
231 231
 		);
232 232
 
233 233
 	}
Please login to merge, or discard this patch.