Passed
Push — master ( bdf164...c6d931 )
by Brian
05:05
created
includes/reports/class-getpaid-graph-downloader.php 2 patches
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -12,219 +12,219 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Graph_Downloader {
14 14
 
15
-	/**
16
-	 * @var GetPaid_Reports_Report
17
-	 */
18
-	public $handler;
19
-
20
-	/**
21
-	 * Class constructor.
22
-	 *
23
-	 */
24
-	public function __construct() {
25
-		$this->handler = new GetPaid_Reports_Report();
26
-	}
27
-
28
-	/**
29
-	 * Prepares the datastore handler.
30
-	 *
31
-	 * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts
32
-	 */
33
-	public function prepare_handler( $graph ) {
34
-
35
-		if ( empty( $this->handler->views[ $graph ] ) ) {
36
-			wp_die( __( 'Invalid Graph', 'invoicing' ), 400 );
37
-		}
38
-
39
-		return new $this->handler->views[ $graph ]['class']();
40
-
41
-	}
42
-
43
-	/**
44
-	 * Prepares the output stream.
45
-	 *
46
-	 * @return resource
47
-	 */
48
-	public function prepare_output() {
49
-
50
-		$output  = fopen( 'php://output', 'w' );
51
-
52
-		if ( false === $output ) {
53
-			wp_die( __( 'Unsupported server', 'invoicing' ), 500 );
54
-		}
55
-
56
-		return $output;
57
-	}
58
-
59
-	/**
60
-	 * Prepares the file type.
61
-	 *
62
-	 * @return string
63
-	 */
64
-	public function prepare_file_type( $graph ) {
65
-
66
-		$file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] );
67
-		$file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) );
68
-
69
-		header( "Content-Type:application/$file_type" );
70
-		header( "Content-Disposition:attachment;filename=$file_name.$file_type" );
71
-
72
-		return $file_type;
73
-	}
74
-
75
-	/**
76
-	 * Handles the actual download.
77
-	 *
78
-	 */
79
-	public function download( $graph ) {
80
-		global $wpdb;
81
-
82
-		$handler   = $this->prepare_handler( $graph );
83
-		$stream    = $this->prepare_output();
84
-		$stats     = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) );
85
-		$headers   = array( $handler->field, 'total', 'total_raw' );
86
-		$file_type = $this->prepare_file_type( $graph );
87
-
88
-		if ( 'csv' == $file_type ) {
89
-			$this->download_csv( $stats, $stream, $headers );
90
-		} else if( 'xml' == $file_type ) {
91
-			$this->download_xml( $stats, $stream, $headers );
92
-		} else {
93
-			$this->download_json( $stats, $stream, $headers );
94
-		}
95
-
96
-		fclose( $stream );
97
-		exit;
98
-	}
99
-
100
-	/**
101
-	 * Downloads graph as csv
102
-	 *
103
-	 * @param array $stats The stats being downloaded.
104
-	 * @param resource $stream The stream to output to.
105
-	 * @param array $headers The fields to stream.
106
-	 * @since       1.0.19
107
-	 */
108
-	public function download_csv( $stats, $stream, $headers ) {
109
-
110
-		// Output the csv column headers.
111
-		fputcsv( $stream, $headers );
112
-
113
-		// Loop through 
114
-		foreach ( $stats as $stat ) {
115
-			$row  = array_values( $this->prepare_row( $stat, $headers ) );
116
-			$row  = array_map( 'maybe_serialize', $row );
117
-			fputcsv( $stream, $row );
118
-		}
119
-
120
-	}
121
-
122
-	/**
123
-	 * Downloads graph as json
124
-	 *
125
-	 * @param array $stats The stats being downloaded.
126
-	 * @param resource $stream The stream to output to.
127
-	 * @param array $headers The fields to stream.
128
-	 * @since       1.0.19
129
-	 */
130
-	public function download_json( $stats, $stream, $headers ) {
131
-
132
-		$prepared = array();
133
-
134
-		// Loop through 
135
-		foreach ( $stats as $stat ) {
136
-			$prepared[] = $this->prepare_row( $stat, $headers );
137
-		}
138
-
139
-		fwrite( $stream, wp_json_encode( $prepared ) );
140
-
141
-	}
142
-
143
-	/**
144
-	 * Downloads graph as xml
145
-	 *
146
-	 * @param array $stats The stats being downloaded.
147
-	 * @param resource $stream The stream to output to.
148
-	 * @param array $headers The fields to stream.
149
-	 * @since       1.0.19
150
-	 */
151
-	public function download_xml( $stats, $stream, $headers ) {
152
-
153
-		$prepared = array();
154
-
155
-		// Loop through 
156
-		foreach ( $stats as $stat ) {
157
-			$prepared[] = $this->prepare_row( $stat, $headers );
158
-		}
159
-
160
-		$xml = new SimpleXMLElement('<?xml version="1.0"?><data></data>');
161
-		$this->convert_array_xml( $prepared, $xml );
162
-
163
-		fwrite( $stream, $xml->asXML() );
164
-
165
-	}
166
-
167
-	/**
168
-	 * Converts stats array to xml
169
-	 *
170
-	 * @access      public
171
-	 * @since      1.0.19
172
-	 */
173
-	public function convert_array_xml( $data, $xml ) {
174
-
175
-		// Loop through 
176
-		foreach ( $data as $key => $value ) {
177
-
178
-			$key = preg_replace( "/[^A-Za-z0-9_\-]/", '', $key );
179
-
180
-			if ( is_array( $value ) ) {
181
-
182
-				if ( is_numeric( $key ) ){
183
-					$key = 'item'.$key; //dealing with <0/>..<n/> issues
184
-				}
185
-
186
-				$subnode = $xml->addChild( $key );
187
-				$this->convert_array_xml( $value, $subnode );
188
-
189
-			} else {
190
-				$xml->addChild( $key, htmlspecialchars( $value ) );
191
-			}
192
-
193
-		}
15
+    /**
16
+     * @var GetPaid_Reports_Report
17
+     */
18
+    public $handler;
19
+
20
+    /**
21
+     * Class constructor.
22
+     *
23
+     */
24
+    public function __construct() {
25
+        $this->handler = new GetPaid_Reports_Report();
26
+    }
27
+
28
+    /**
29
+     * Prepares the datastore handler.
30
+     *
31
+     * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts
32
+     */
33
+    public function prepare_handler( $graph ) {
34
+
35
+        if ( empty( $this->handler->views[ $graph ] ) ) {
36
+            wp_die( __( 'Invalid Graph', 'invoicing' ), 400 );
37
+        }
38
+
39
+        return new $this->handler->views[ $graph ]['class']();
40
+
41
+    }
42
+
43
+    /**
44
+     * Prepares the output stream.
45
+     *
46
+     * @return resource
47
+     */
48
+    public function prepare_output() {
49
+
50
+        $output  = fopen( 'php://output', 'w' );
51
+
52
+        if ( false === $output ) {
53
+            wp_die( __( 'Unsupported server', 'invoicing' ), 500 );
54
+        }
55
+
56
+        return $output;
57
+    }
58
+
59
+    /**
60
+     * Prepares the file type.
61
+     *
62
+     * @return string
63
+     */
64
+    public function prepare_file_type( $graph ) {
65
+
66
+        $file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] );
67
+        $file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) );
68
+
69
+        header( "Content-Type:application/$file_type" );
70
+        header( "Content-Disposition:attachment;filename=$file_name.$file_type" );
71
+
72
+        return $file_type;
73
+    }
74
+
75
+    /**
76
+     * Handles the actual download.
77
+     *
78
+     */
79
+    public function download( $graph ) {
80
+        global $wpdb;
81
+
82
+        $handler   = $this->prepare_handler( $graph );
83
+        $stream    = $this->prepare_output();
84
+        $stats     = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) );
85
+        $headers   = array( $handler->field, 'total', 'total_raw' );
86
+        $file_type = $this->prepare_file_type( $graph );
87
+
88
+        if ( 'csv' == $file_type ) {
89
+            $this->download_csv( $stats, $stream, $headers );
90
+        } else if( 'xml' == $file_type ) {
91
+            $this->download_xml( $stats, $stream, $headers );
92
+        } else {
93
+            $this->download_json( $stats, $stream, $headers );
94
+        }
95
+
96
+        fclose( $stream );
97
+        exit;
98
+    }
99
+
100
+    /**
101
+     * Downloads graph as csv
102
+     *
103
+     * @param array $stats The stats being downloaded.
104
+     * @param resource $stream The stream to output to.
105
+     * @param array $headers The fields to stream.
106
+     * @since       1.0.19
107
+     */
108
+    public function download_csv( $stats, $stream, $headers ) {
109
+
110
+        // Output the csv column headers.
111
+        fputcsv( $stream, $headers );
112
+
113
+        // Loop through 
114
+        foreach ( $stats as $stat ) {
115
+            $row  = array_values( $this->prepare_row( $stat, $headers ) );
116
+            $row  = array_map( 'maybe_serialize', $row );
117
+            fputcsv( $stream, $row );
118
+        }
119
+
120
+    }
121
+
122
+    /**
123
+     * Downloads graph as json
124
+     *
125
+     * @param array $stats The stats being downloaded.
126
+     * @param resource $stream The stream to output to.
127
+     * @param array $headers The fields to stream.
128
+     * @since       1.0.19
129
+     */
130
+    public function download_json( $stats, $stream, $headers ) {
131
+
132
+        $prepared = array();
133
+
134
+        // Loop through 
135
+        foreach ( $stats as $stat ) {
136
+            $prepared[] = $this->prepare_row( $stat, $headers );
137
+        }
138
+
139
+        fwrite( $stream, wp_json_encode( $prepared ) );
140
+
141
+    }
142
+
143
+    /**
144
+     * Downloads graph as xml
145
+     *
146
+     * @param array $stats The stats being downloaded.
147
+     * @param resource $stream The stream to output to.
148
+     * @param array $headers The fields to stream.
149
+     * @since       1.0.19
150
+     */
151
+    public function download_xml( $stats, $stream, $headers ) {
152
+
153
+        $prepared = array();
154
+
155
+        // Loop through 
156
+        foreach ( $stats as $stat ) {
157
+            $prepared[] = $this->prepare_row( $stat, $headers );
158
+        }
159
+
160
+        $xml = new SimpleXMLElement('<?xml version="1.0"?><data></data>');
161
+        $this->convert_array_xml( $prepared, $xml );
162
+
163
+        fwrite( $stream, $xml->asXML() );
164
+
165
+    }
166
+
167
+    /**
168
+     * Converts stats array to xml
169
+     *
170
+     * @access      public
171
+     * @since      1.0.19
172
+     */
173
+    public function convert_array_xml( $data, $xml ) {
174
+
175
+        // Loop through 
176
+        foreach ( $data as $key => $value ) {
177
+
178
+            $key = preg_replace( "/[^A-Za-z0-9_\-]/", '', $key );
179
+
180
+            if ( is_array( $value ) ) {
181
+
182
+                if ( is_numeric( $key ) ){
183
+                    $key = 'item'.$key; //dealing with <0/>..<n/> issues
184
+                }
185
+
186
+                $subnode = $xml->addChild( $key );
187
+                $this->convert_array_xml( $value, $subnode );
188
+
189
+            } else {
190
+                $xml->addChild( $key, htmlspecialchars( $value ) );
191
+            }
192
+
193
+        }
194 194
 
195
-	}
196
-
197
-	/**
198
-	 * Prepares a single row for download.
199
-	 *
200
-	 * @param stdClass|array $row The row to prepare..
201
-	 * @param array $fields The fields to stream.
202
-	 * @since       1.0.19
203
-	 * @return array
204
-	 */
205
-	public function prepare_row( $row, $fields ) {
195
+    }
196
+
197
+    /**
198
+     * Prepares a single row for download.
199
+     *
200
+     * @param stdClass|array $row The row to prepare..
201
+     * @param array $fields The fields to stream.
202
+     * @since       1.0.19
203
+     * @return array
204
+     */
205
+    public function prepare_row( $row, $fields ) {
206 206
 
207
-		$prepared = array();
208
-		$row      = (array) $row;
207
+        $prepared = array();
208
+        $row      = (array) $row;
209 209
 
210
-		foreach ( $fields as $field ) {
210
+        foreach ( $fields as $field ) {
211 211
 
212
-			if ( $field === 'total' ) {
213
-				$prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES );
214
-				continue;
215
-			}
212
+            if ( $field === 'total' ) {
213
+                $prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES );
214
+                continue;
215
+            }
216 216
 
217
-			if ( $field === 'total_raw' ) {
218
-				$prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) );
219
-				continue;
220
-			}
217
+            if ( $field === 'total_raw' ) {
218
+                $prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) );
219
+                continue;
220
+            }
221 221
 
222
-			$prepared[ $field ] = strip_tags( $row[ $field ] );
222
+            $prepared[ $field ] = strip_tags( $row[ $field ] );
223 223
 
224
-		}
224
+        }
225 225
 
226
-		return $prepared;
227
-	}
226
+        return $prepared;
227
+    }
228 228
 
229 229
 
230 230
 }
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 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_Graph_Downloader Class.
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return GetPaid_Reports_Report_Items|GetPaid_Reports_Report_Gateways|GetPaid_Reports_Report_Discounts
32 32
 	 */
33
-	public function prepare_handler( $graph ) {
33
+	public function prepare_handler($graph) {
34 34
 
35
-		if ( empty( $this->handler->views[ $graph ] ) ) {
36
-			wp_die( __( 'Invalid Graph', 'invoicing' ), 400 );
35
+		if (empty($this->handler->views[$graph])) {
36
+			wp_die(__('Invalid Graph', 'invoicing'), 400);
37 37
 		}
38 38
 
39
-		return new $this->handler->views[ $graph ]['class']();
39
+		return new $this->handler->views[$graph]['class']();
40 40
 
41 41
 	}
42 42
 
@@ -47,10 +47,10 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function prepare_output() {
49 49
 
50
-		$output  = fopen( 'php://output', 'w' );
50
+		$output = fopen('php://output', 'w');
51 51
 
52
-		if ( false === $output ) {
53
-			wp_die( __( 'Unsupported server', 'invoicing' ), 500 );
52
+		if (false === $output) {
53
+			wp_die(__('Unsupported server', 'invoicing'), 500);
54 54
 		}
55 55
 
56 56
 		return $output;
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @return string
63 63
 	 */
64
-	public function prepare_file_type( $graph ) {
64
+	public function prepare_file_type($graph) {
65 65
 
66
-		$file_type = empty( $_REQUEST['file_type'] ) ? 'csv' : sanitize_text_field( $_REQUEST['file_type'] );
67
-		$file_name = wpinv_sanitize_key( "getpaid-$graph-" . current_time( 'Y-m-d' ) );
66
+		$file_type = empty($_REQUEST['file_type']) ? 'csv' : sanitize_text_field($_REQUEST['file_type']);
67
+		$file_name = wpinv_sanitize_key("getpaid-$graph-" . current_time('Y-m-d'));
68 68
 
69
-		header( "Content-Type:application/$file_type" );
70
-		header( "Content-Disposition:attachment;filename=$file_name.$file_type" );
69
+		header("Content-Type:application/$file_type");
70
+		header("Content-Disposition:attachment;filename=$file_name.$file_type");
71 71
 
72 72
 		return $file_type;
73 73
 	}
@@ -76,24 +76,24 @@  discard block
 block discarded – undo
76 76
 	 * Handles the actual download.
77 77
 	 *
78 78
 	 */
79
-	public function download( $graph ) {
79
+	public function download($graph) {
80 80
 		global $wpdb;
81 81
 
82
-		$handler   = $this->prepare_handler( $graph );
82
+		$handler   = $this->prepare_handler($graph);
83 83
 		$stream    = $this->prepare_output();
84
-		$stats     = $wpdb->get_results( $handler->get_sql( $handler->get_range() ) );
85
-		$headers   = array( $handler->field, 'total', 'total_raw' );
86
-		$file_type = $this->prepare_file_type( $graph );
87
-
88
-		if ( 'csv' == $file_type ) {
89
-			$this->download_csv( $stats, $stream, $headers );
90
-		} else if( 'xml' == $file_type ) {
91
-			$this->download_xml( $stats, $stream, $headers );
84
+		$stats     = $wpdb->get_results($handler->get_sql($handler->get_range()));
85
+		$headers   = array($handler->field, 'total', 'total_raw');
86
+		$file_type = $this->prepare_file_type($graph);
87
+
88
+		if ('csv' == $file_type) {
89
+			$this->download_csv($stats, $stream, $headers);
90
+		} else if ('xml' == $file_type) {
91
+			$this->download_xml($stats, $stream, $headers);
92 92
 		} else {
93
-			$this->download_json( $stats, $stream, $headers );
93
+			$this->download_json($stats, $stream, $headers);
94 94
 		}
95 95
 
96
-		fclose( $stream );
96
+		fclose($stream);
97 97
 		exit;
98 98
 	}
99 99
 
@@ -105,16 +105,16 @@  discard block
 block discarded – undo
105 105
 	 * @param array $headers The fields to stream.
106 106
 	 * @since       1.0.19
107 107
 	 */
108
-	public function download_csv( $stats, $stream, $headers ) {
108
+	public function download_csv($stats, $stream, $headers) {
109 109
 
110 110
 		// Output the csv column headers.
111
-		fputcsv( $stream, $headers );
111
+		fputcsv($stream, $headers);
112 112
 
113 113
 		// Loop through 
114
-		foreach ( $stats as $stat ) {
115
-			$row  = array_values( $this->prepare_row( $stat, $headers ) );
116
-			$row  = array_map( 'maybe_serialize', $row );
117
-			fputcsv( $stream, $row );
114
+		foreach ($stats as $stat) {
115
+			$row  = array_values($this->prepare_row($stat, $headers));
116
+			$row  = array_map('maybe_serialize', $row);
117
+			fputcsv($stream, $row);
118 118
 		}
119 119
 
120 120
 	}
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
 	 * @param array $headers The fields to stream.
128 128
 	 * @since       1.0.19
129 129
 	 */
130
-	public function download_json( $stats, $stream, $headers ) {
130
+	public function download_json($stats, $stream, $headers) {
131 131
 
132 132
 		$prepared = array();
133 133
 
134 134
 		// Loop through 
135
-		foreach ( $stats as $stat ) {
136
-			$prepared[] = $this->prepare_row( $stat, $headers );
135
+		foreach ($stats as $stat) {
136
+			$prepared[] = $this->prepare_row($stat, $headers);
137 137
 		}
138 138
 
139
-		fwrite( $stream, wp_json_encode( $prepared ) );
139
+		fwrite($stream, wp_json_encode($prepared));
140 140
 
141 141
 	}
142 142
 
@@ -148,19 +148,19 @@  discard block
 block discarded – undo
148 148
 	 * @param array $headers The fields to stream.
149 149
 	 * @since       1.0.19
150 150
 	 */
151
-	public function download_xml( $stats, $stream, $headers ) {
151
+	public function download_xml($stats, $stream, $headers) {
152 152
 
153 153
 		$prepared = array();
154 154
 
155 155
 		// Loop through 
156
-		foreach ( $stats as $stat ) {
157
-			$prepared[] = $this->prepare_row( $stat, $headers );
156
+		foreach ($stats as $stat) {
157
+			$prepared[] = $this->prepare_row($stat, $headers);
158 158
 		}
159 159
 
160 160
 		$xml = new SimpleXMLElement('<?xml version="1.0"?><data></data>');
161
-		$this->convert_array_xml( $prepared, $xml );
161
+		$this->convert_array_xml($prepared, $xml);
162 162
 
163
-		fwrite( $stream, $xml->asXML() );
163
+		fwrite($stream, $xml->asXML());
164 164
 
165 165
 	}
166 166
 
@@ -170,24 +170,24 @@  discard block
 block discarded – undo
170 170
 	 * @access      public
171 171
 	 * @since      1.0.19
172 172
 	 */
173
-	public function convert_array_xml( $data, $xml ) {
173
+	public function convert_array_xml($data, $xml) {
174 174
 
175 175
 		// Loop through 
176
-		foreach ( $data as $key => $value ) {
176
+		foreach ($data as $key => $value) {
177 177
 
178
-			$key = preg_replace( "/[^A-Za-z0-9_\-]/", '', $key );
178
+			$key = preg_replace("/[^A-Za-z0-9_\-]/", '', $key);
179 179
 
180
-			if ( is_array( $value ) ) {
180
+			if (is_array($value)) {
181 181
 
182
-				if ( is_numeric( $key ) ){
183
-					$key = 'item'.$key; //dealing with <0/>..<n/> issues
182
+				if (is_numeric($key)) {
183
+					$key = 'item' . $key; //dealing with <0/>..<n/> issues
184 184
 				}
185 185
 
186
-				$subnode = $xml->addChild( $key );
187
-				$this->convert_array_xml( $value, $subnode );
186
+				$subnode = $xml->addChild($key);
187
+				$this->convert_array_xml($value, $subnode);
188 188
 
189 189
 			} else {
190
-				$xml->addChild( $key, htmlspecialchars( $value ) );
190
+				$xml->addChild($key, htmlspecialchars($value));
191 191
 			}
192 192
 
193 193
 		}
@@ -202,24 +202,24 @@  discard block
 block discarded – undo
202 202
 	 * @since       1.0.19
203 203
 	 * @return array
204 204
 	 */
205
-	public function prepare_row( $row, $fields ) {
205
+	public function prepare_row($row, $fields) {
206 206
 
207 207
 		$prepared = array();
208 208
 		$row      = (array) $row;
209 209
 
210
-		foreach ( $fields as $field ) {
210
+		foreach ($fields as $field) {
211 211
 
212
-			if ( $field === 'total' ) {
213
-				$prepared[ $field ] = html_entity_decode( strip_tags( wpinv_price( $row['total'] ) ), ENT_QUOTES );
212
+			if ($field === 'total') {
213
+				$prepared[$field] = html_entity_decode(strip_tags(wpinv_price($row['total'])), ENT_QUOTES);
214 214
 				continue;
215 215
 			}
216 216
 
217
-			if ( $field === 'total_raw' ) {
218
-				$prepared[ $field ] = wpinv_round_amount( wpinv_sanitize_amount( $row['total'] ) );
217
+			if ($field === 'total_raw') {
218
+				$prepared[$field] = wpinv_round_amount(wpinv_sanitize_amount($row['total']));
219 219
 				continue;
220 220
 			}
221 221
 
222
-			$prepared[ $field ] = strip_tags( $row[ $field ] );
222
+			$prepared[$field] = strip_tags($row[$field]);
223 223
 
224 224
 		}
225 225
 
Please login to merge, or discard this patch.
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-invoice-exporter.php 2 patches
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -12,197 +12,197 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Invoice_Exporter extends GetPaid_Graph_Downloader {
14 14
 
15
-	/**
16
-	 * Retrieves invoices query args.
17
-	 * 
18
-	 * @param string $post_type post type to retrieve.
19
-	 * @param array $args Args to search for.
20
-	 * @return array
21
-	 */
22
-	public function get_invoice_query_args( $post_type, $args ) {
23
-
24
-		$query_args = array(
25
-			'post_type'              => $post_type,
26
-			'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
27
-			'posts_per_page'         => -1,
28
-			'no_found_rows'          => true,
29
-			'update_post_term_cache' => false,
30
-			'fields'                 => 'ids',
31
-		);
32
-
33
-		if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
-			$query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
35
-		}
36
-
37
-		$date_query = array();
38
-		if ( ! empty( $args['to_date'] ) ) {
39
-			$date_query['before'] = wpinv_clean( $args['to_date'] );
40
-		}
41
-
42
-		if ( ! empty( $args['from_date'] ) ) {
43
-			$date_query['after'] = wpinv_clean( $args['from_date'] );
44
-		}
45
-
46
-		if ( ! empty( $date_query ) ) {
47
-			$date_query['inclusive']  = true;
48
-			$query_args['date_query'] = array( $date_query );
49
-		}
50
-
51
-		return $query_args;
52
-	}
53
-
54
-	/**
55
-	 * Retrieves invoices.
56
-	 * 
57
-	 * @param array $query_args WP_Query args.
58
-	 * @return WPInv_Invoice[]
59
-	 */
60
-	public function get_invoices( $query_args ) {
61
-
62
-		// Get invoices.
63
-		$invoices = new WP_Query( $query_args );
64
-
65
-		// Prepare the results.
66
-		return array_map( 'wpinv_get_invoice', $invoices->posts );
67
-
68
-	}
69
-
70
-	/**
71
-	 * Handles the actual download.
72
-	 *
73
-	 */
74
-	public function export( $post_type, $args ) {
75
-
76
-		$invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
77
-		$stream    = $this->prepare_output();
78
-		$headers   = $this->get_export_fields( $post_type );
79
-		$file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
80
-
81
-		if ( 'csv' == $file_type ) {
82
-			$this->download_csv( $invoices, $stream, $headers );
83
-		} else if( 'xml' == $file_type ) {
84
-			$this->download_xml( $invoices, $stream, $headers );
85
-		} else {
86
-			$this->download_json( $invoices, $stream, $headers );
87
-		}
88
-
89
-		fclose( $stream );
90
-		exit;
91
-	}
92
-
93
-	/**
94
-	 * Prepares a single invoice for download.
95
-	 *
96
-	 * @param WPInv_Invoice $invoice The invoice to prepare..
97
-	 * @param array $fields The fields to stream.
98
-	 * @since       1.0.19
99
-	 * @return array
100
-	 */
101
-	public function prepare_row( $invoice, $fields ) {
102
-
103
-		$prepared      = array();
104
-		$amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
105
-
106
-		foreach ( $fields as $field ) {
107
-
108
-			$value  = '';
109
-			$method = "get_$field";
110
-
111
-			if ( method_exists( $invoice, $method ) ) {
112
-				$value  = $invoice->$method();
113
-			}
114
-
115
-			if ( in_array( $field, $amount_fields ) ) {
116
-				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
117
-			}
118
-
119
-			if ( $field === 'items' ) {
120
-				$value  = $invoice->get_cart_details();
121
-			}
122
-
123
-			$prepared[ $field ] = wpinv_clean( $value );
124
-
125
-		}
126
-
127
-		return $prepared;
128
-	}
129
-
130
-	/**
131
-	 * Retrieves export fields.
132
-	 *
133
-	 * @param string $post_type
134
-	 * @since       1.0.19
135
-	 * @return array
136
-	 */
137
-	public function get_export_fields( $post_type ) {
138
-
139
-		$fields = array(
140
-			'id',
141
-			'parent_id',
142
-			'status',
143
-			'date_created',
144
-			'date_modified',
145
-			'date_due',
146
-			'date_completed',
147
-			'number',
148
-			'key',
149
-			'description',
150
-			'post_type',
151
-			'mode',
152
-			'customer_id',
153
-			'customer_first_name',
154
-			'customer_last_name',
155
-			'customer_phone',
156
-			'customer_email',
157
-			'customer_country',
158
-			'customer_city',
159
-			'customer_state',
160
-			'customer_zip',
161
-			'customer_company',
162
-			'customer_vat_number',
163
-			'customer_address',
164
-			'subtotal',
165
-			'total_discount',
166
-			'total_tax',
167
-			'total_fees',
168
-			'fees',
169
-			'discounts',
170
-			'taxes',
171
-			'items',
172
-			'payment_form',
173
-			'discount_code',
174
-			'gateway',
175
-			'transaction_id',
176
-			'currency',
177
-			'disable_taxes',
178
-			'subscription_id',
179
-			'remote_subscription_id',
180
-			'is_viewed',
181
-			'email_cc',
182
-			'template',
183
-			'created_via'
184
-    	);
185
-
186
-		return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
187
-	}
188
-
189
-	/**
190
-	 * Retrieves amount fields.
191
-	 *
192
-	 * @param string $post_type
193
-	 * @since       1.0.19
194
-	 * @return array
195
-	 */
196
-	public function get_amount_fields( $post_type ) {
197
-
198
-		$fields = array(
199
-			'subtotal',
200
-			'total_discount',
201
-			'total_tax',
202
-			'total_fees'
203
-    	);
204
-
205
-		return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
206
-	}
15
+    /**
16
+     * Retrieves invoices query args.
17
+     * 
18
+     * @param string $post_type post type to retrieve.
19
+     * @param array $args Args to search for.
20
+     * @return array
21
+     */
22
+    public function get_invoice_query_args( $post_type, $args ) {
23
+
24
+        $query_args = array(
25
+            'post_type'              => $post_type,
26
+            'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
27
+            'posts_per_page'         => -1,
28
+            'no_found_rows'          => true,
29
+            'update_post_term_cache' => false,
30
+            'fields'                 => 'ids',
31
+        );
32
+
33
+        if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
+            $query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
35
+        }
36
+
37
+        $date_query = array();
38
+        if ( ! empty( $args['to_date'] ) ) {
39
+            $date_query['before'] = wpinv_clean( $args['to_date'] );
40
+        }
41
+
42
+        if ( ! empty( $args['from_date'] ) ) {
43
+            $date_query['after'] = wpinv_clean( $args['from_date'] );
44
+        }
45
+
46
+        if ( ! empty( $date_query ) ) {
47
+            $date_query['inclusive']  = true;
48
+            $query_args['date_query'] = array( $date_query );
49
+        }
50
+
51
+        return $query_args;
52
+    }
53
+
54
+    /**
55
+     * Retrieves invoices.
56
+     * 
57
+     * @param array $query_args WP_Query args.
58
+     * @return WPInv_Invoice[]
59
+     */
60
+    public function get_invoices( $query_args ) {
61
+
62
+        // Get invoices.
63
+        $invoices = new WP_Query( $query_args );
64
+
65
+        // Prepare the results.
66
+        return array_map( 'wpinv_get_invoice', $invoices->posts );
67
+
68
+    }
69
+
70
+    /**
71
+     * Handles the actual download.
72
+     *
73
+     */
74
+    public function export( $post_type, $args ) {
75
+
76
+        $invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
77
+        $stream    = $this->prepare_output();
78
+        $headers   = $this->get_export_fields( $post_type );
79
+        $file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
80
+
81
+        if ( 'csv' == $file_type ) {
82
+            $this->download_csv( $invoices, $stream, $headers );
83
+        } else if( 'xml' == $file_type ) {
84
+            $this->download_xml( $invoices, $stream, $headers );
85
+        } else {
86
+            $this->download_json( $invoices, $stream, $headers );
87
+        }
88
+
89
+        fclose( $stream );
90
+        exit;
91
+    }
92
+
93
+    /**
94
+     * Prepares a single invoice for download.
95
+     *
96
+     * @param WPInv_Invoice $invoice The invoice to prepare..
97
+     * @param array $fields The fields to stream.
98
+     * @since       1.0.19
99
+     * @return array
100
+     */
101
+    public function prepare_row( $invoice, $fields ) {
102
+
103
+        $prepared      = array();
104
+        $amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
105
+
106
+        foreach ( $fields as $field ) {
107
+
108
+            $value  = '';
109
+            $method = "get_$field";
110
+
111
+            if ( method_exists( $invoice, $method ) ) {
112
+                $value  = $invoice->$method();
113
+            }
114
+
115
+            if ( in_array( $field, $amount_fields ) ) {
116
+                $value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
117
+            }
118
+
119
+            if ( $field === 'items' ) {
120
+                $value  = $invoice->get_cart_details();
121
+            }
122
+
123
+            $prepared[ $field ] = wpinv_clean( $value );
124
+
125
+        }
126
+
127
+        return $prepared;
128
+    }
129
+
130
+    /**
131
+     * Retrieves export fields.
132
+     *
133
+     * @param string $post_type
134
+     * @since       1.0.19
135
+     * @return array
136
+     */
137
+    public function get_export_fields( $post_type ) {
138
+
139
+        $fields = array(
140
+            'id',
141
+            'parent_id',
142
+            'status',
143
+            'date_created',
144
+            'date_modified',
145
+            'date_due',
146
+            'date_completed',
147
+            'number',
148
+            'key',
149
+            'description',
150
+            'post_type',
151
+            'mode',
152
+            'customer_id',
153
+            'customer_first_name',
154
+            'customer_last_name',
155
+            'customer_phone',
156
+            'customer_email',
157
+            'customer_country',
158
+            'customer_city',
159
+            'customer_state',
160
+            'customer_zip',
161
+            'customer_company',
162
+            'customer_vat_number',
163
+            'customer_address',
164
+            'subtotal',
165
+            'total_discount',
166
+            'total_tax',
167
+            'total_fees',
168
+            'fees',
169
+            'discounts',
170
+            'taxes',
171
+            'items',
172
+            'payment_form',
173
+            'discount_code',
174
+            'gateway',
175
+            'transaction_id',
176
+            'currency',
177
+            'disable_taxes',
178
+            'subscription_id',
179
+            'remote_subscription_id',
180
+            'is_viewed',
181
+            'email_cc',
182
+            'template',
183
+            'created_via'
184
+        );
185
+
186
+        return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
187
+    }
188
+
189
+    /**
190
+     * Retrieves amount fields.
191
+     *
192
+     * @param string $post_type
193
+     * @since       1.0.19
194
+     * @return array
195
+     */
196
+    public function get_amount_fields( $post_type ) {
197
+
198
+        $fields = array(
199
+            'subtotal',
200
+            'total_discount',
201
+            'total_tax',
202
+            'total_fees'
203
+        );
204
+
205
+        return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
206
+    }
207 207
 
208 208
 }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 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_Invoice_Exporter Class.
@@ -19,33 +19,33 @@  discard block
 block discarded – undo
19 19
 	 * @param array $args Args to search for.
20 20
 	 * @return array
21 21
 	 */
22
-	public function get_invoice_query_args( $post_type, $args ) {
22
+	public function get_invoice_query_args($post_type, $args) {
23 23
 
24 24
 		$query_args = array(
25 25
 			'post_type'              => $post_type,
26
-			'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
26
+			'post_status'            => array_keys(wpinv_get_invoice_statuses(true, false, $post_type)),
27 27
 			'posts_per_page'         => -1,
28 28
 			'no_found_rows'          => true,
29 29
 			'update_post_term_cache' => false,
30 30
 			'fields'                 => 'ids',
31 31
 		);
32 32
 
33
-		if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
-			$query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
33
+		if (!empty($args['status']) && in_array($args['status'], $query_args['post_status'], true)) {
34
+			$query_args['post_status'] = wpinv_clean(wpinv_parse_list($args['status']));
35 35
 		}
36 36
 
37 37
 		$date_query = array();
38
-		if ( ! empty( $args['to_date'] ) ) {
39
-			$date_query['before'] = wpinv_clean( $args['to_date'] );
38
+		if (!empty($args['to_date'])) {
39
+			$date_query['before'] = wpinv_clean($args['to_date']);
40 40
 		}
41 41
 
42
-		if ( ! empty( $args['from_date'] ) ) {
43
-			$date_query['after'] = wpinv_clean( $args['from_date'] );
42
+		if (!empty($args['from_date'])) {
43
+			$date_query['after'] = wpinv_clean($args['from_date']);
44 44
 		}
45 45
 
46
-		if ( ! empty( $date_query ) ) {
46
+		if (!empty($date_query)) {
47 47
 			$date_query['inclusive']  = true;
48
-			$query_args['date_query'] = array( $date_query );
48
+			$query_args['date_query'] = array($date_query);
49 49
 		}
50 50
 
51 51
 		return $query_args;
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 	 * @param array $query_args WP_Query args.
58 58
 	 * @return WPInv_Invoice[]
59 59
 	 */
60
-	public function get_invoices( $query_args ) {
60
+	public function get_invoices($query_args) {
61 61
 
62 62
 		// Get invoices.
63
-		$invoices = new WP_Query( $query_args );
63
+		$invoices = new WP_Query($query_args);
64 64
 
65 65
 		// Prepare the results.
66
-		return array_map( 'wpinv_get_invoice', $invoices->posts );
66
+		return array_map('wpinv_get_invoice', $invoices->posts);
67 67
 
68 68
 	}
69 69
 
@@ -71,22 +71,22 @@  discard block
 block discarded – undo
71 71
 	 * Handles the actual download.
72 72
 	 *
73 73
 	 */
74
-	public function export( $post_type, $args ) {
74
+	public function export($post_type, $args) {
75 75
 
76
-		$invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
76
+		$invoices  = $this->get_invoices($this->get_invoice_query_args($post_type, $args));
77 77
 		$stream    = $this->prepare_output();
78
-		$headers   = $this->get_export_fields( $post_type );
79
-		$file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
78
+		$headers   = $this->get_export_fields($post_type);
79
+		$file_type = $this->prepare_file_type(strtolower(getpaid_get_post_type_label($post_type)));
80 80
 
81
-		if ( 'csv' == $file_type ) {
82
-			$this->download_csv( $invoices, $stream, $headers );
83
-		} else if( 'xml' == $file_type ) {
84
-			$this->download_xml( $invoices, $stream, $headers );
81
+		if ('csv' == $file_type) {
82
+			$this->download_csv($invoices, $stream, $headers);
83
+		} else if ('xml' == $file_type) {
84
+			$this->download_xml($invoices, $stream, $headers);
85 85
 		} else {
86
-			$this->download_json( $invoices, $stream, $headers );
86
+			$this->download_json($invoices, $stream, $headers);
87 87
 		}
88 88
 
89
-		fclose( $stream );
89
+		fclose($stream);
90 90
 		exit;
91 91
 	}
92 92
 
@@ -98,29 +98,29 @@  discard block
 block discarded – undo
98 98
 	 * @since       1.0.19
99 99
 	 * @return array
100 100
 	 */
101
-	public function prepare_row( $invoice, $fields ) {
101
+	public function prepare_row($invoice, $fields) {
102 102
 
103 103
 		$prepared      = array();
104
-		$amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
104
+		$amount_fields = $this->get_amount_fields($invoice->get_post_type());
105 105
 
106
-		foreach ( $fields as $field ) {
106
+		foreach ($fields as $field) {
107 107
 
108 108
 			$value  = '';
109 109
 			$method = "get_$field";
110 110
 
111
-			if ( method_exists( $invoice, $method ) ) {
112
-				$value  = $invoice->$method();
111
+			if (method_exists($invoice, $method)) {
112
+				$value = $invoice->$method();
113 113
 			}
114 114
 
115
-			if ( in_array( $field, $amount_fields ) ) {
116
-				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
115
+			if (in_array($field, $amount_fields)) {
116
+				$value = wpinv_round_amount(wpinv_sanitize_amount($value));
117 117
 			}
118 118
 
119
-			if ( $field === 'items' ) {
120
-				$value  = $invoice->get_cart_details();
119
+			if ($field === 'items') {
120
+				$value = $invoice->get_cart_details();
121 121
 			}
122 122
 
123
-			$prepared[ $field ] = wpinv_clean( $value );
123
+			$prepared[$field] = wpinv_clean($value);
124 124
 
125 125
 		}
126 126
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @since       1.0.19
135 135
 	 * @return array
136 136
 	 */
137
-	public function get_export_fields( $post_type ) {
137
+	public function get_export_fields($post_type) {
138 138
 
139 139
 		$fields = array(
140 140
 			'id',
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			'created_via'
184 184
     	);
185 185
 
186
-		return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
186
+		return apply_filters('getpaid_invoice_exporter_get_fields', $fields, $post_type);
187 187
 	}
188 188
 
189 189
 	/**
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @since       1.0.19
194 194
 	 * @return array
195 195
 	 */
196
-	public function get_amount_fields( $post_type ) {
196
+	public function get_amount_fields($post_type) {
197 197
 
198 198
 		$fields = array(
199 199
 			'subtotal',
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 			'total_fees'
203 203
     	);
204 204
 
205
-		return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
205
+		return apply_filters('getpaid_invoice_exporter_get_amount_fields', $fields, $post_type);
206 206
 	}
207 207
 
208 208
 }
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.