Passed
Push — master ( d8a99d...7ebec5 )
by Brian
10:32
created
includes/reports/class-getpaid-reports-export.php 2 patches
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -12,47 +12,47 @@  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
-		$this->display_subscription_export();
26
-		echo '</div>';
27
-
28
-	}
29
-
30
-	/**
31
-	 * Retrieves the download url.
32
-	 *
33
-	 */
34
-	public function get_download_url( $post_type ) {
35
-
36
-		return wp_nonce_url(
37
-			add_query_arg(
38
-				array(
39
-					'getpaid-admin-action' => 'export_invoices',
40
-					'post_type'            => urlencode( $post_type ),
41
-				)
42
-			),
43
-			'getpaid-nonce',
44
-			'getpaid-nonce'
45
-		);
46
-
47
-	}
48
-
49
-	/**
50
-	 * Displays a single post type export card.
51
-	 *
52
-	 */
53
-	public function display_post_type_export( $post_type ) {
54
-
55
-		?>
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
+        $this->display_subscription_export();
26
+        echo '</div>';
27
+
28
+    }
29
+
30
+    /**
31
+     * Retrieves the download url.
32
+     *
33
+     */
34
+    public function get_download_url( $post_type ) {
35
+
36
+        return wp_nonce_url(
37
+            add_query_arg(
38
+                array(
39
+                    'getpaid-admin-action' => 'export_invoices',
40
+                    'post_type'            => urlencode( $post_type ),
41
+                )
42
+            ),
43
+            'getpaid-nonce',
44
+            'getpaid-nonce'
45
+        );
46
+
47
+    }
48
+
49
+    /**
50
+     * Displays a single post type export card.
51
+     *
52
+     */
53
+    public function display_post_type_export( $post_type ) {
54
+
55
+        ?>
56 56
 
57 57
 		<div class="col-12 col-md-6">
58 58
 			<div class="card m-0 p-0" style="max-width:100%">
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 				<div class="card-header">
61 61
 					<strong>
62 62
 						<?php
63
-							printf(
64
-								esc_html__( 'Export %s', 'invoicing' ),
65
-								esc_html( getpaid_get_post_type_label( $post_type ) )
66
-							);
67
-						?>
63
+                            printf(
64
+                                esc_html__( 'Export %s', 'invoicing' ),
65
+                                esc_html( getpaid_get_post_type_label( $post_type ) )
66
+                            );
67
+                        ?>
68 68
 					</strong>
69 69
 				</div>
70 70
 
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 					<form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>">
74 74
 
75 75
 						<?php
76
-							$this->generate_from_date( $post_type );
77
-							$this->generate_to_date( $post_type );
78
-							$this->generate_post_status_select( $post_type );
79
-							$this->generate_file_type_select( $post_type );
80
-							submit_button( __( 'Download', 'invoicing' ) );
81
-						?>
76
+                            $this->generate_from_date( $post_type );
77
+                            $this->generate_to_date( $post_type );
78
+                            $this->generate_post_status_select( $post_type );
79
+                            $this->generate_file_type_select( $post_type );
80
+                            submit_button( __( 'Download', 'invoicing' ) );
81
+                        ?>
82 82
 
83 83
 					</form>
84 84
 
@@ -89,135 +89,135 @@  discard block
 block discarded – undo
89 89
 
90 90
 		<?php
91 91
 
92
-	}
93
-
94
-	/**
95
-	 * Generates the from date input field.
96
-	 *
97
-	 */
98
-	public function generate_from_date( $post_type ) {
99
-
100
-		aui()->input(
101
-			array(
102
-				'type'             => 'datepicker',
103
-				'id'               => esc_attr( "$post_type-from_date" ),
104
-				'name'             => 'from_date',
105
-				'label'            => __( 'From Date', 'invoicing' ),
106
-				'label_type'       => 'vertical',
107
-				'placeholder'      => 'YYYY-MM-DD',
108
-				'extra_attributes' => array(
109
-					'data-enable-time' => 'false',
110
-					'data-allow-input' => 'true',
111
-				),
112
-			),
113
-			true
114
-		);
115
-
116
-	}
117
-
118
-	/**
119
-	 * Generates the to date input field.
120
-	 *
121
-	 */
122
-	public function generate_to_date( $post_type ) {
123
-
124
-		aui()->input(
125
-			array(
126
-				'type'             => 'datepicker',
127
-				'id'               => esc_attr( "$post_type-to_date" ),
128
-				'name'             => 'to_date',
129
-				'label'            => __( 'To Date', 'invoicing' ),
130
-				'label_type'       => 'vertical',
131
-				'placeholder'      => 'YYYY-MM-DD',
132
-				'extra_attributes' => array(
133
-					'data-enable-time' => 'false',
134
-					'data-allow-input' => 'true',
135
-				),
136
-			),
137
-			true
138
-		);
139
-	}
140
-
141
-	/**
142
-	 * Generates the to post status select field.
143
-	 *
144
-	 */
145
-	public function generate_post_status_select( $post_type ) {
146
-
147
-		if ( 'subscriptions' === $post_type ) {
148
-			$options = getpaid_get_subscription_statuses();
149
-		} else {
150
-			$options = wpinv_get_invoice_statuses( true, false, $post_type );
151
-		}
152
-
153
-		aui()->select(
154
-			array(
155
-				'name'        => 'status',
156
-				'id'          => esc_attr( "$post_type-status" ),
157
-				'placeholder' => __( 'All Statuses', 'invoicing' ),
158
-				'label'       => __( 'Status', 'invoicing' ),
159
-				'label_type'  => 'vertical',
160
-				'label_class' => 'd-block',
161
-				'options'     => $options,
162
-			),
163
-			true
164
-		);
165
-
166
-	}
167
-
168
-	/**
169
-	 * Generates the to file type select field.
170
-	 *
171
-	 */
172
-	public function generate_file_type_select( $post_type ) {
173
-
174
-		aui()->select(
175
-			array(
176
-				'name'        => 'file_type',
177
-				'id'          => esc_attr( "$post_type-file_type" ),
178
-				'placeholder' => __( 'Select File Type', 'invoicing' ),
179
-				'label'       => __( 'Export File', 'invoicing' ),
180
-				'label_type'  => 'vertical',
181
-				'label_class' => 'd-block',
182
-				'value'       => 'csv',
183
-				'options'     => array(
184
-					'csv'  => __( 'CSV', 'invoicing' ),
185
-					'xml'  => __( 'XML', 'invoicing' ),
186
-					'json' => __( 'JSON', 'invoicing' ),
187
-				),
188
-			),
189
-			true
190
-		);
191
-
192
-	}
193
-
194
-	/**
195
-	 * Displays a field's markup.
196
-	 *
197
-	 */
198
-	public function display_markup( $markup ) {
199
-
200
-		echo wp_kses(
201
-			str_replace(
202
-				array(
203
-					'form-control',
204
-					'custom-select',
205
-				),
206
-				'regular-text',
207
-				$markup
208
-			),
209
-			getpaid_allowed_html()
210
-		);
211
-
212
-	}
213
-
214
-	/**
215
-	 * Displays a subscription export card.
216
-	 *
217
-	 */
218
-	public function display_subscription_export() {
219
-
220
-		?>
92
+    }
93
+
94
+    /**
95
+     * Generates the from date input field.
96
+     *
97
+     */
98
+    public function generate_from_date( $post_type ) {
99
+
100
+        aui()->input(
101
+            array(
102
+                'type'             => 'datepicker',
103
+                'id'               => esc_attr( "$post_type-from_date" ),
104
+                'name'             => 'from_date',
105
+                'label'            => __( 'From Date', 'invoicing' ),
106
+                'label_type'       => 'vertical',
107
+                'placeholder'      => 'YYYY-MM-DD',
108
+                'extra_attributes' => array(
109
+                    'data-enable-time' => 'false',
110
+                    'data-allow-input' => 'true',
111
+                ),
112
+            ),
113
+            true
114
+        );
115
+
116
+    }
117
+
118
+    /**
119
+     * Generates the to date input field.
120
+     *
121
+     */
122
+    public function generate_to_date( $post_type ) {
123
+
124
+        aui()->input(
125
+            array(
126
+                'type'             => 'datepicker',
127
+                'id'               => esc_attr( "$post_type-to_date" ),
128
+                'name'             => 'to_date',
129
+                'label'            => __( 'To Date', 'invoicing' ),
130
+                'label_type'       => 'vertical',
131
+                'placeholder'      => 'YYYY-MM-DD',
132
+                'extra_attributes' => array(
133
+                    'data-enable-time' => 'false',
134
+                    'data-allow-input' => 'true',
135
+                ),
136
+            ),
137
+            true
138
+        );
139
+    }
140
+
141
+    /**
142
+     * Generates the to post status select field.
143
+     *
144
+     */
145
+    public function generate_post_status_select( $post_type ) {
146
+
147
+        if ( 'subscriptions' === $post_type ) {
148
+            $options = getpaid_get_subscription_statuses();
149
+        } else {
150
+            $options = wpinv_get_invoice_statuses( true, false, $post_type );
151
+        }
152
+
153
+        aui()->select(
154
+            array(
155
+                'name'        => 'status',
156
+                'id'          => esc_attr( "$post_type-status" ),
157
+                'placeholder' => __( 'All Statuses', 'invoicing' ),
158
+                'label'       => __( 'Status', 'invoicing' ),
159
+                'label_type'  => 'vertical',
160
+                'label_class' => 'd-block',
161
+                'options'     => $options,
162
+            ),
163
+            true
164
+        );
165
+
166
+    }
167
+
168
+    /**
169
+     * Generates the to file type select field.
170
+     *
171
+     */
172
+    public function generate_file_type_select( $post_type ) {
173
+
174
+        aui()->select(
175
+            array(
176
+                'name'        => 'file_type',
177
+                'id'          => esc_attr( "$post_type-file_type" ),
178
+                'placeholder' => __( 'Select File Type', 'invoicing' ),
179
+                'label'       => __( 'Export File', 'invoicing' ),
180
+                'label_type'  => 'vertical',
181
+                'label_class' => 'd-block',
182
+                'value'       => 'csv',
183
+                'options'     => array(
184
+                    'csv'  => __( 'CSV', 'invoicing' ),
185
+                    'xml'  => __( 'XML', 'invoicing' ),
186
+                    'json' => __( 'JSON', 'invoicing' ),
187
+                ),
188
+            ),
189
+            true
190
+        );
191
+
192
+    }
193
+
194
+    /**
195
+     * Displays a field's markup.
196
+     *
197
+     */
198
+    public function display_markup( $markup ) {
199
+
200
+        echo wp_kses(
201
+            str_replace(
202
+                array(
203
+                    'form-control',
204
+                    'custom-select',
205
+                ),
206
+                'regular-text',
207
+                $markup
208
+            ),
209
+            getpaid_allowed_html()
210
+        );
211
+
212
+    }
213
+
214
+    /**
215
+     * Displays a subscription export card.
216
+     *
217
+     */
218
+    public function display_subscription_export() {
219
+
220
+        ?>
221 221
 
222 222
 		<div class="col-12 col-md-6">
223 223
 			<div class="card m-0 p-0" style="max-width:100%">
@@ -233,12 +233,12 @@  discard block
 block discarded – undo
233 233
 					<form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>">
234 234
 
235 235
 						<?php
236
-							$this->generate_from_date( 'subscriptions' );
237
-							$this->generate_to_date( 'subscriptions' );
238
-							$this->generate_post_status_select( 'subscriptions' );
239
-							$this->generate_file_type_select( 'subscriptions' );
240
-							submit_button( __( 'Download', 'invoicing' ) );
241
-						?>
236
+                            $this->generate_from_date( 'subscriptions' );
237
+                            $this->generate_to_date( 'subscriptions' );
238
+                            $this->generate_post_status_select( 'subscriptions' );
239
+                            $this->generate_file_type_select( 'subscriptions' );
240
+                            submit_button( __( 'Download', 'invoicing' ) );
241
+                        ?>
242 242
 
243 243
 					</form>
244 244
 
@@ -249,6 +249,6 @@  discard block
 block discarded – undo
249 249
 
250 250
 		<?php
251 251
 
252
-	}
252
+    }
253 253
 
254 254
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 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
 		$this->display_subscription_export();
26 26
 		echo '</div>';
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
 	 * Retrieves the download url.
32 32
 	 *
33 33
 	 */
34
-	public function get_download_url( $post_type ) {
34
+	public function get_download_url($post_type) {
35 35
 
36 36
 		return wp_nonce_url(
37 37
 			add_query_arg(
38 38
 				array(
39 39
 					'getpaid-admin-action' => 'export_invoices',
40
-					'post_type'            => urlencode( $post_type ),
40
+					'post_type'            => urlencode($post_type),
41 41
 				)
42 42
 			),
43 43
 			'getpaid-nonce',
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * Displays a single post type export card.
51 51
 	 *
52 52
 	 */
53
-	public function display_post_type_export( $post_type ) {
53
+	public function display_post_type_export($post_type) {
54 54
 
55 55
 		?>
56 56
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 					<strong>
62 62
 						<?php
63 63
 							printf(
64
-								esc_html__( 'Export %s', 'invoicing' ),
65
-								esc_html( getpaid_get_post_type_label( $post_type ) )
64
+								esc_html__('Export %s', 'invoicing'),
65
+								esc_html(getpaid_get_post_type_label($post_type))
66 66
 							);
67 67
 						?>
68 68
 					</strong>
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 
71 71
 				<div class="card-body">
72 72
 
73
-					<form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>">
73
+					<form method="post" action="<?php echo esc_url($this->get_download_url($post_type)); ?>">
74 74
 
75 75
 						<?php
76
-							$this->generate_from_date( $post_type );
77
-							$this->generate_to_date( $post_type );
78
-							$this->generate_post_status_select( $post_type );
79
-							$this->generate_file_type_select( $post_type );
80
-							submit_button( __( 'Download', 'invoicing' ) );
76
+							$this->generate_from_date($post_type);
77
+							$this->generate_to_date($post_type);
78
+							$this->generate_post_status_select($post_type);
79
+							$this->generate_file_type_select($post_type);
80
+							submit_button(__('Download', 'invoicing'));
81 81
 						?>
82 82
 
83 83
 					</form>
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
 	 * Generates the from date input field.
96 96
 	 *
97 97
 	 */
98
-	public function generate_from_date( $post_type ) {
98
+	public function generate_from_date($post_type) {
99 99
 
100 100
 		aui()->input(
101 101
 			array(
102 102
 				'type'             => 'datepicker',
103
-				'id'               => esc_attr( "$post_type-from_date" ),
103
+				'id'               => esc_attr("$post_type-from_date"),
104 104
 				'name'             => 'from_date',
105
-				'label'            => __( 'From Date', 'invoicing' ),
105
+				'label'            => __('From Date', 'invoicing'),
106 106
 				'label_type'       => 'vertical',
107 107
 				'placeholder'      => 'YYYY-MM-DD',
108 108
 				'extra_attributes' => array(
@@ -119,14 +119,14 @@  discard block
 block discarded – undo
119 119
 	 * Generates the to date input field.
120 120
 	 *
121 121
 	 */
122
-	public function generate_to_date( $post_type ) {
122
+	public function generate_to_date($post_type) {
123 123
 
124 124
 		aui()->input(
125 125
 			array(
126 126
 				'type'             => 'datepicker',
127
-				'id'               => esc_attr( "$post_type-to_date" ),
127
+				'id'               => esc_attr("$post_type-to_date"),
128 128
 				'name'             => 'to_date',
129
-				'label'            => __( 'To Date', 'invoicing' ),
129
+				'label'            => __('To Date', 'invoicing'),
130 130
 				'label_type'       => 'vertical',
131 131
 				'placeholder'      => 'YYYY-MM-DD',
132 132
 				'extra_attributes' => array(
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
 	 * Generates the to post status select field.
143 143
 	 *
144 144
 	 */
145
-	public function generate_post_status_select( $post_type ) {
145
+	public function generate_post_status_select($post_type) {
146 146
 
147
-		if ( 'subscriptions' === $post_type ) {
147
+		if ('subscriptions' === $post_type) {
148 148
 			$options = getpaid_get_subscription_statuses();
149 149
 		} else {
150
-			$options = wpinv_get_invoice_statuses( true, false, $post_type );
150
+			$options = wpinv_get_invoice_statuses(true, false, $post_type);
151 151
 		}
152 152
 
153 153
 		aui()->select(
154 154
 			array(
155 155
 				'name'        => 'status',
156
-				'id'          => esc_attr( "$post_type-status" ),
157
-				'placeholder' => __( 'All Statuses', 'invoicing' ),
158
-				'label'       => __( 'Status', 'invoicing' ),
156
+				'id'          => esc_attr("$post_type-status"),
157
+				'placeholder' => __('All Statuses', 'invoicing'),
158
+				'label'       => __('Status', 'invoicing'),
159 159
 				'label_type'  => 'vertical',
160 160
 				'label_class' => 'd-block',
161 161
 				'options'     => $options,
@@ -169,21 +169,21 @@  discard block
 block discarded – undo
169 169
 	 * Generates the to file type select field.
170 170
 	 *
171 171
 	 */
172
-	public function generate_file_type_select( $post_type ) {
172
+	public function generate_file_type_select($post_type) {
173 173
 
174 174
 		aui()->select(
175 175
 			array(
176 176
 				'name'        => 'file_type',
177
-				'id'          => esc_attr( "$post_type-file_type" ),
178
-				'placeholder' => __( 'Select File Type', 'invoicing' ),
179
-				'label'       => __( 'Export File', 'invoicing' ),
177
+				'id'          => esc_attr("$post_type-file_type"),
178
+				'placeholder' => __('Select File Type', 'invoicing'),
179
+				'label'       => __('Export File', 'invoicing'),
180 180
 				'label_type'  => 'vertical',
181 181
 				'label_class' => 'd-block',
182 182
 				'value'       => 'csv',
183 183
 				'options'     => array(
184
-					'csv'  => __( 'CSV', 'invoicing' ),
185
-					'xml'  => __( 'XML', 'invoicing' ),
186
-					'json' => __( 'JSON', 'invoicing' ),
184
+					'csv'  => __('CSV', 'invoicing'),
185
+					'xml'  => __('XML', 'invoicing'),
186
+					'json' => __('JSON', 'invoicing'),
187 187
 				),
188 188
 			),
189 189
 			true
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * Displays a field's markup.
196 196
 	 *
197 197
 	 */
198
-	public function display_markup( $markup ) {
198
+	public function display_markup($markup) {
199 199
 
200 200
 		echo wp_kses(
201 201
 			str_replace(
@@ -224,20 +224,20 @@  discard block
 block discarded – undo
224 224
 
225 225
 				<div class="card-header">
226 226
 					<strong>
227
-						<?php esc_html_e( 'Export Subscriptions', 'invoicing' ); ?>
227
+						<?php esc_html_e('Export Subscriptions', 'invoicing'); ?>
228 228
 					</strong>
229 229
 				</div>
230 230
 
231 231
 				<div class="card-body">
232 232
 
233
-					<form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>">
233
+					<form method="post" action="<?php echo esc_url($this->get_download_url('subscriptions')); ?>">
234 234
 
235 235
 						<?php
236
-							$this->generate_from_date( 'subscriptions' );
237
-							$this->generate_to_date( 'subscriptions' );
238
-							$this->generate_post_status_select( 'subscriptions' );
239
-							$this->generate_file_type_select( 'subscriptions' );
240
-							submit_button( __( 'Download', 'invoicing' ) );
236
+							$this->generate_from_date('subscriptions');
237
+							$this->generate_to_date('subscriptions');
238
+							$this->generate_post_status_select('subscriptions');
239
+							$this->generate_file_type_select('subscriptions');
240
+							submit_button(__('Download', 'invoicing'));
241 241
 						?>
242 242
 
243 243
 					</form>
Please login to merge, or discard this patch.