Passed
Push — master ( 92055d...17a77b )
by Brian
12:06
created
includes/reports/class-getpaid-reports-export.php 1 patch
Indentation   +181 added lines, -181 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->display_markup( $this->generate_from_date( $post_type ) );
77
-							$this->display_markup( $this->generate_to_date( $post_type ) );
78
-							$this->display_markup( $this->generate_post_status_select( $post_type ) );
79
-							$this->display_markup( $this->generate_file_type_select( $post_type ) );
80
-							submit_button( __( 'Download', 'invoicing' ) );
81
-						?>
76
+                            $this->display_markup( $this->generate_from_date( $post_type ) );
77
+                            $this->display_markup( $this->generate_to_date( $post_type ) );
78
+                            $this->display_markup( $this->generate_post_status_select( $post_type ) );
79
+                            $this->display_markup( $this->generate_file_type_select( $post_type ) );
80
+                            submit_button( __( 'Download', 'invoicing' ) );
81
+                        ?>
82 82
 
83 83
 					</form>
84 84
 
@@ -89,128 +89,128 @@  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
-		return 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
-				'placeholder'      => 'YYYY-MM-DD',
107
-				'extra_attributes' => array(
108
-					'data-enable-time' => 'false',
109
-					'data-allow-input' => 'true',
110
-				),
111
-			),
112
-			false
113
-		);
114
-
115
-	}
116
-
117
-	/**
118
-	 * Generates the to date input field.
119
-	 *
120
-	 */
121
-	public function generate_to_date( $post_type ) {
122
-
123
-		return aui()->input(
124
-			array(
125
-				'name'        => 'to_date',
126
-				'id'          => esc_attr( "$post_type-to_date" ),
127
-				'placeholder' => 'yy-mm-dd',
128
-				'label'       => __( 'To Date', 'invoicing' ),
129
-				'label_type'  => 'vertical',
130
-				'label_class' => 'd-block',
131
-				'type'        => 'datepicker',
132
-			)
133
-		);
134
-
135
-	}
136
-
137
-	/**
138
-	 * Generates the to post status select field.
139
-	 *
140
-	 */
141
-	public function generate_post_status_select( $post_type ) {
142
-
143
-		if ( 'subscriptions' === $post_type ) {
144
-			$options = getpaid_get_subscription_statuses();
145
-		} else {
146
-			$options = wpinv_get_invoice_statuses( true, false, $post_type );
147
-		}
148
-
149
-		return aui()->select(
150
-			array(
151
-				'name'        => 'status',
152
-				'id'          => esc_attr( "$post_type-status" ),
153
-				'placeholder' => __( 'All Statuses', 'invoicing' ),
154
-				'label'       => __( 'Status', 'invoicing' ),
155
-				'label_type'  => 'vertical',
156
-				'label_class' => 'd-block',
157
-				'options'     => $options,
158
-			)
159
-		);
160
-
161
-	}
162
-
163
-	/**
164
-	 * Generates the to file type select field.
165
-	 *
166
-	 */
167
-	public function generate_file_type_select( $post_type ) {
168
-
169
-		return aui()->select(
170
-			array(
171
-				'name'        => 'file_type',
172
-				'id'          => esc_attr( "$post_type-file_type" ),
173
-				'placeholder' => __( 'Select File Type', 'invoicing' ),
174
-				'label'       => __( 'Export File', 'invoicing' ),
175
-				'label_type'  => 'vertical',
176
-				'label_class' => 'd-block',
177
-				'options'     => array(
178
-					'csv'  => __( 'CSV', 'invoicing' ),
179
-					'xml'  => __( 'XML', 'invoicing' ),
180
-					'json' => __( 'JSON', 'invoicing' ),
181
-				),
182
-			)
183
-		);
184
-
185
-	}
186
-
187
-	/**
188
-	 * Displays a field's markup.
189
-	 *
190
-	 */
191
-	public function display_markup( $markup ) {
192
-
193
-		echo wp_kses(
194
-			str_replace(
195
-				array(
196
-					'form-control',
197
-					'custom-select',
198
-				),
199
-				'regular-text',
200
-				$markup
201
-			),
202
-			getpaid_allowed_html()
203
-		);
204
-
205
-	}
206
-
207
-	/**
208
-	 * Displays a subscription export card.
209
-	 *
210
-	 */
211
-	public function display_subscription_export() {
212
-
213
-		?>
92
+    }
93
+
94
+    /**
95
+     * Generates the from date input field.
96
+     *
97
+     */
98
+    public function generate_from_date( $post_type ) {
99
+
100
+        return 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
+                'placeholder'      => 'YYYY-MM-DD',
107
+                'extra_attributes' => array(
108
+                    'data-enable-time' => 'false',
109
+                    'data-allow-input' => 'true',
110
+                ),
111
+            ),
112
+            false
113
+        );
114
+
115
+    }
116
+
117
+    /**
118
+     * Generates the to date input field.
119
+     *
120
+     */
121
+    public function generate_to_date( $post_type ) {
122
+
123
+        return aui()->input(
124
+            array(
125
+                'name'        => 'to_date',
126
+                'id'          => esc_attr( "$post_type-to_date" ),
127
+                'placeholder' => 'yy-mm-dd',
128
+                'label'       => __( 'To Date', 'invoicing' ),
129
+                'label_type'  => 'vertical',
130
+                'label_class' => 'd-block',
131
+                'type'        => 'datepicker',
132
+            )
133
+        );
134
+
135
+    }
136
+
137
+    /**
138
+     * Generates the to post status select field.
139
+     *
140
+     */
141
+    public function generate_post_status_select( $post_type ) {
142
+
143
+        if ( 'subscriptions' === $post_type ) {
144
+            $options = getpaid_get_subscription_statuses();
145
+        } else {
146
+            $options = wpinv_get_invoice_statuses( true, false, $post_type );
147
+        }
148
+
149
+        return aui()->select(
150
+            array(
151
+                'name'        => 'status',
152
+                'id'          => esc_attr( "$post_type-status" ),
153
+                'placeholder' => __( 'All Statuses', 'invoicing' ),
154
+                'label'       => __( 'Status', 'invoicing' ),
155
+                'label_type'  => 'vertical',
156
+                'label_class' => 'd-block',
157
+                'options'     => $options,
158
+            )
159
+        );
160
+
161
+    }
162
+
163
+    /**
164
+     * Generates the to file type select field.
165
+     *
166
+     */
167
+    public function generate_file_type_select( $post_type ) {
168
+
169
+        return aui()->select(
170
+            array(
171
+                'name'        => 'file_type',
172
+                'id'          => esc_attr( "$post_type-file_type" ),
173
+                'placeholder' => __( 'Select File Type', 'invoicing' ),
174
+                'label'       => __( 'Export File', 'invoicing' ),
175
+                'label_type'  => 'vertical',
176
+                'label_class' => 'd-block',
177
+                'options'     => array(
178
+                    'csv'  => __( 'CSV', 'invoicing' ),
179
+                    'xml'  => __( 'XML', 'invoicing' ),
180
+                    'json' => __( 'JSON', 'invoicing' ),
181
+                ),
182
+            )
183
+        );
184
+
185
+    }
186
+
187
+    /**
188
+     * Displays a field's markup.
189
+     *
190
+     */
191
+    public function display_markup( $markup ) {
192
+
193
+        echo wp_kses(
194
+            str_replace(
195
+                array(
196
+                    'form-control',
197
+                    'custom-select',
198
+                ),
199
+                'regular-text',
200
+                $markup
201
+            ),
202
+            getpaid_allowed_html()
203
+        );
204
+
205
+    }
206
+
207
+    /**
208
+     * Displays a subscription export card.
209
+     *
210
+     */
211
+    public function display_subscription_export() {
212
+
213
+        ?>
214 214
 
215 215
 		<div class="col-12 col-md-6">
216 216
 			<div class="card m-0 p-0" style="max-width:100%">
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
 					<form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>">
227 227
 
228 228
 						<?php
229
-							$this->display_markup( $this->generate_from_date( 'subscriptions' ) );
230
-							$this->display_markup( $this->generate_to_date( 'subscriptions' ) );
231
-							$this->display_markup( $this->generate_post_status_select( 'subscriptions' ) );
232
-							$this->display_markup( $this->generate_file_type_select( 'subscriptions' ) );
233
-							submit_button( __( 'Download', 'invoicing' ) );
234
-						?>
229
+                            $this->display_markup( $this->generate_from_date( 'subscriptions' ) );
230
+                            $this->display_markup( $this->generate_to_date( 'subscriptions' ) );
231
+                            $this->display_markup( $this->generate_post_status_select( 'subscriptions' ) );
232
+                            $this->display_markup( $this->generate_file_type_select( 'subscriptions' ) );
233
+                            submit_button( __( 'Download', 'invoicing' ) );
234
+                        ?>
235 235
 
236 236
 					</form>
237 237
 
@@ -242,6 +242,6 @@  discard block
 block discarded – undo
242 242
 
243 243
 		<?php
244 244
 
245
-	}
245
+    }
246 246
 
247 247
 }
Please login to merge, or discard this patch.