Completed
Pull Request — master (#420)
by Valerio
05:57
created
includes/admin/reporting/class-export-earnings.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Earnings Export Class
4
- *
5
- * This class handles earnings export
6
- *
7
- * @package     Give
8
- * @subpackage  Admin/Reports
9
- * @copyright   Copyright (c) 2015, WordImpress
10
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
- * @since       1.0
12
- */
3
+	 * Earnings Export Class
4
+	 *
5
+	 * This class handles earnings export
6
+	 *
7
+	 * @package     Give
8
+	 * @subpackage  Admin/Reports
9
+	 * @copyright   Copyright (c) 2015, WordImpress
10
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
+	 * @since       1.0
12
+	 */
13 13
 
14 14
 // Exit if accessed directly
15 15
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 	 * @return void
39 39
 	 */
40 40
 	public function headers() {
41
-		ignore_user_abort( true );
41
+		ignore_user_abort(true);
42 42
 
43
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
44
-			set_time_limit( 0 );
43
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
44
+			set_time_limit(0);
45 45
 		}
46 46
 
47 47
 		nocache_headers();
48
-		header( 'Content-Type: text/csv; charset=utf-8' );
49
-		header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' );
50
-		header( "Expires: 0" );
48
+		header('Content-Type: text/csv; charset=utf-8');
49
+		header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv');
50
+		header("Expires: 0");
51 51
 
52 52
 	}
53 53
 
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 	public function csv_cols() {
62 62
 
63 63
 		$cols = array(
64
-			'date'      => __( 'Date', 'give' ),
65
-			'donations' => __( 'Donations', 'give' ),
66
-			'earnings'  => __( 'Income', 'give' ) . ' (' . html_entity_decode( give_currency_filter( '' ) ) . ')'
64
+			'date'      => __('Date', 'give'),
65
+			'donations' => __('Donations', 'give'),
66
+			'earnings'  => __('Income', 'give').' ('.html_entity_decode(give_currency_filter('')).')'
67 67
 		);
68 68
 
69 69
 		return $cols;
@@ -78,28 +78,28 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function get_data() {
80 80
 
81
-		$start_year  = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' );
82
-		$end_year    = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' );
83
-		$start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' );
84
-		$end_month   = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' );
81
+		$start_year  = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y');
82
+		$end_year    = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y');
83
+		$start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n');
84
+		$end_month   = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n');
85 85
 
86 86
 		$data  = array();
87 87
 		$year  = $start_year;
88 88
 		$stats = new Give_Payment_Stats;
89 89
 
90
-		while ( $year <= $end_year ) {
90
+		while ($year <= $end_year) {
91 91
 
92
-			if ( $year == $start_year && $year == $end_year ) {
92
+			if ($year == $start_year && $year == $end_year) {
93 93
 
94 94
 				$m1 = $start_month;
95 95
 				$m2 = $end_month;
96 96
 
97
-			} elseif ( $year == $start_year ) {
97
+			} elseif ($year == $start_year) {
98 98
 
99 99
 				$m1 = $start_month;
100 100
 				$m2 = 12;
101 101
 
102
-			} elseif ( $year == $end_year ) {
102
+			} elseif ($year == $end_year) {
103 103
 
104 104
 				$m1 = 1;
105 105
 				$m2 = $end_month;
@@ -111,28 +111,28 @@  discard block
 block discarded – undo
111 111
 
112 112
 			}
113 113
 
114
-			while ( $m1 <= $m2 ) {
114
+			while ($m1 <= $m2) {
115 115
 
116
-				$date1 = mktime( 0, 0, 0, $m1, 1, $year );
117
-				$date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year );
116
+				$date1 = mktime(0, 0, 0, $m1, 1, $year);
117
+				$date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year);
118 118
 
119 119
 				$data[] = array(
120
-					'date'      => date_i18n( 'F Y', $date1 ),
121
-					'donations' => $stats->get_sales( 0, $date1, $date2, array( 'publish', 'revoked' ) ),
122
-					'earnings'  => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ) ),
120
+					'date'      => date_i18n('F Y', $date1),
121
+					'donations' => $stats->get_sales(0, $date1, $date2, array('publish', 'revoked')),
122
+					'earnings'  => give_format_amount($stats->get_earnings(0, $date1, $date2)),
123 123
 				);
124 124
 
125
-				$m1 ++;
125
+				$m1++;
126 126
 
127 127
 			}
128 128
 
129 129
 
130
-			$year ++;
130
+			$year++;
131 131
 
132 132
 		}
133 133
 
134
-		$data = apply_filters( 'give_export_get_data', $data );
135
-		$data = apply_filters( 'give_export_get_data_' . $this->export_type, $data );
134
+		$data = apply_filters('give_export_get_data', $data);
135
+		$data = apply_filters('give_export_get_data_'.$this->export_type, $data);
136 136
 
137 137
 		return $data;
138 138
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/class-export-payments.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Payments Export Class
4
- *
5
- * This class handles payment export
6
- *
7
- * @package     Give
8
- * @subpackage  Admin/Reports
9
- * @copyright   Copyright (c) 2015, WordImpress
10
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
- * @since       1.4.4
12
- */
3
+	 * Payments Export Class
4
+	 *
5
+	 * This class handles payment export
6
+	 *
7
+	 * @package     Give
8
+	 * @subpackage  Admin/Reports
9
+	 * @copyright   Copyright (c) 2015, WordImpress
10
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
+	 * @since       1.4.4
12
+	 */
13 13
 
14 14
 // Exit if accessed directly
15 15
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -37,19 +37,19 @@  discard block
 block discarded – undo
37 37
 	 * @return void
38 38
 	 */
39 39
 	public function headers() {
40
-		ignore_user_abort( true );
40
+		ignore_user_abort(true);
41 41
 
42
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
43
-			set_time_limit( 0 );
42
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
43
+			set_time_limit(0);
44 44
 		}
45 45
 
46
-		$month = isset( $_POST['month'] ) ? absint( $_POST['month'] ) : date( 'n' );
47
-		$year  = isset( $_POST['year'] ) ? absint( $_POST['year'] ) : date( 'Y' );
46
+		$month = isset($_POST['month']) ? absint($_POST['month']) : date('n');
47
+		$year  = isset($_POST['year']) ? absint($_POST['year']) : date('Y');
48 48
 
49 49
 		nocache_headers();
50
-		header( 'Content-Type: text/csv; charset=utf-8' );
51
-		header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_payments_export_filename', 'give-export-' . $this->export_type . '-' . $month . '-' . $year ) . '.csv' );
52
-		header( "Expires: 0" );
50
+		header('Content-Type: text/csv; charset=utf-8');
51
+		header('Content-Disposition: attachment; filename='.apply_filters('give_payments_export_filename', 'give-export-'.$this->export_type.'-'.$month.'-'.$year).'.csv');
52
+		header("Expires: 0");
53 53
 	}
54 54
 
55 55
 	/**
@@ -63,30 +63,30 @@  discard block
 block discarded – undo
63 63
 		global $give_options;
64 64
 
65 65
 		$cols = array(
66
-			'id'       => __( 'ID', 'give' ), // unaltered payment ID (use for querying)
67
-			'seq_id'   => __( 'Payment Number', 'give' ), // sequential payment ID
68
-			'email'    => __( 'Email', 'give' ),
69
-			'first'    => __( 'First Name', 'give' ),
70
-			'last'     => __( 'Last Name', 'give' ),
71
-			'address1' => __( 'Address', 'give' ),
72
-			'address2' => __( 'Address (Line 2)', 'give' ),
73
-			'city'     => __( 'City', 'give' ),
74
-			'state'    => __( 'State', 'give' ),
75
-			'country'  => __( 'Country', 'give' ),
76
-			'zip'      => __( 'Zip Code', 'give' ),
77
-			'amount'   => __( 'Donation Amount', 'give' ) . ' (' . html_entity_decode( give_currency_filter( '' ) ) . ')',
78
-			'form_id'  => __( 'Form ID', 'give' ),
79
-			'form'     => __( 'Form Title', 'give' ),
80
-			'gateway'  => __( 'Payment Method', 'give' ),
81
-			'trans_id' => __( 'Transaction ID', 'give' ),
82
-			'key'      => __( 'Purchase Key', 'give' ),
83
-			'date'     => __( 'Date', 'give' ),
84
-			'user'     => __( 'User', 'give' ),
85
-			'status'   => __( 'Status', 'give' )
66
+			'id'       => __('ID', 'give'), // unaltered payment ID (use for querying)
67
+			'seq_id'   => __('Payment Number', 'give'), // sequential payment ID
68
+			'email'    => __('Email', 'give'),
69
+			'first'    => __('First Name', 'give'),
70
+			'last'     => __('Last Name', 'give'),
71
+			'address1' => __('Address', 'give'),
72
+			'address2' => __('Address (Line 2)', 'give'),
73
+			'city'     => __('City', 'give'),
74
+			'state'    => __('State', 'give'),
75
+			'country'  => __('Country', 'give'),
76
+			'zip'      => __('Zip Code', 'give'),
77
+			'amount'   => __('Donation Amount', 'give').' ('.html_entity_decode(give_currency_filter('')).')',
78
+			'form_id'  => __('Form ID', 'give'),
79
+			'form'     => __('Form Title', 'give'),
80
+			'gateway'  => __('Payment Method', 'give'),
81
+			'trans_id' => __('Transaction ID', 'give'),
82
+			'key'      => __('Purchase Key', 'give'),
83
+			'date'     => __('Date', 'give'),
84
+			'user'     => __('User', 'give'),
85
+			'status'   => __('Status', 'give')
86 86
 		);
87 87
 
88
-		if ( ! give_get_option( 'enable_sequential' ) ) {
89
-			unset( $cols['seq_id'] );
88
+		if ( ! give_get_option('enable_sequential')) {
89
+			unset($cols['seq_id']);
90 90
 		}
91 91
 
92 92
 		return $cols;
@@ -106,57 +106,57 @@  discard block
 block discarded – undo
106 106
 
107 107
 		$data = array();
108 108
 
109
-		$payments = give_get_payments( array(
109
+		$payments = give_get_payments(array(
110 110
 			'offset' => 0,
111
-			'number' => - 1,
111
+			'number' => -1,
112 112
 			'mode'   => give_is_test_mode() ? 'test' : 'live',
113
-			'status' => isset( $_POST['give_export_payment_status'] ) ? $_POST['give_export_payment_status'] : 'any',
114
-			'month'  => isset( $_POST['month'] ) ? absint( $_POST['month'] ) : date( 'n' ),
115
-			'year'   => isset( $_POST['year'] ) ? absint( $_POST['year'] ) : date( 'Y' )
116
-		) );
113
+			'status' => isset($_POST['give_export_payment_status']) ? $_POST['give_export_payment_status'] : 'any',
114
+			'month'  => isset($_POST['month']) ? absint($_POST['month']) : date('n'),
115
+			'year'   => isset($_POST['year']) ? absint($_POST['year']) : date('Y')
116
+		));
117 117
 
118
-		foreach ( $payments as $payment ) {
119
-			$payment_meta = give_get_payment_meta( $payment->ID );
120
-			$user_info    = give_get_payment_meta_user_info( $payment->ID );
121
-			$total        = give_get_payment_amount( $payment->ID );
122
-			$user_id      = isset( $user_info['id'] ) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email'];
118
+		foreach ($payments as $payment) {
119
+			$payment_meta = give_get_payment_meta($payment->ID);
120
+			$user_info    = give_get_payment_meta_user_info($payment->ID);
121
+			$total        = give_get_payment_amount($payment->ID);
122
+			$user_id      = isset($user_info['id']) && $user_info['id'] != - 1 ? $user_info['id'] : $user_info['email'];
123 123
 
124 124
 			$form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : '';
125 125
 			$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
126 126
 
127
-			if ( is_numeric( $user_id ) ) {
128
-				$user = get_userdata( $user_id );
127
+			if (is_numeric($user_id)) {
128
+				$user = get_userdata($user_id);
129 129
 			} else {
130 130
 				$user = false;
131 131
 			}
132 132
 
133 133
 			$data[] = array(
134 134
 				'id'       => $payment->ID,
135
-				'seq_id'   => give_get_payment_number( $payment->ID ),
135
+				'seq_id'   => give_get_payment_number($payment->ID),
136 136
 				'email'    => $payment_meta['email'],
137 137
 				'first'    => $user_info['first_name'],
138 138
 				'last'     => $user_info['last_name'],
139
-				'address1' => isset( $user_info['address']['line1'] ) ? $user_info['address']['line1'] : '',
140
-				'address2' => isset( $user_info['address']['line2'] ) ? $user_info['address']['line2'] : '',
141
-				'city'     => isset( $user_info['address']['city'] ) ? $user_info['address']['city'] : '',
142
-				'state'    => isset( $user_info['address']['state'] ) ? $user_info['address']['state'] : '',
143
-				'country'  => isset( $user_info['address']['country'] ) ? $user_info['address']['country'] : '',
144
-				'zip'      => isset( $user_info['address']['zip'] ) ? $user_info['address']['zip'] : '',
145
-				'amount'   => html_entity_decode( give_format_amount( $total ) ),
139
+				'address1' => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '',
140
+				'address2' => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '',
141
+				'city'     => isset($user_info['address']['city']) ? $user_info['address']['city'] : '',
142
+				'state'    => isset($user_info['address']['state']) ? $user_info['address']['state'] : '',
143
+				'country'  => isset($user_info['address']['country']) ? $user_info['address']['country'] : '',
144
+				'zip'      => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '',
145
+				'amount'   => html_entity_decode(give_format_amount($total)),
146 146
 				'form_id'  => $form_id,
147 147
 				'form'     => $form_title,
148
-				'gateway'  => give_get_gateway_admin_label( get_post_meta( $payment->ID, '_give_payment_gateway', true ) ),
149
-				'trans_id' => give_get_payment_transaction_id( $payment->ID ),
148
+				'gateway'  => give_get_gateway_admin_label(get_post_meta($payment->ID, '_give_payment_gateway', true)),
149
+				'trans_id' => give_get_payment_transaction_id($payment->ID),
150 150
 				'key'      => $payment_meta['key'],
151 151
 				'date'     => $payment->post_date,
152
-				'user'     => $user ? $user->display_name : __( 'guest', 'give' ),
153
-				'status'   => give_get_payment_status( $payment, true )
152
+				'user'     => $user ? $user->display_name : __('guest', 'give'),
153
+				'status'   => give_get_payment_status($payment, true)
154 154
 			);
155 155
 
156 156
 		}
157 157
 
158
-		$data = apply_filters( 'give_export_get_data', $data );
159
-		$data = apply_filters( 'give_export_get_data_' . $this->export_type, $data );
158
+		$data = apply_filters('give_export_get_data', $data);
159
+		$data = apply_filters('give_export_get_data_'.$this->export_type, $data);
160 160
 
161 161
 		return $data;
162 162
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/class-export.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Export Class
4
- *
5
- * This is the base class for all export methods. Each data export type (donors, payments, etc) extend this class
6
- *
7
- * @package     Give
8
- * @subpackage  Admin/Reports
9
- * @copyright   Copyright (c) 2015, WordImpress
10
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
- * @since       1.0
12
- */
3
+	 * Export Class
4
+	 *
5
+	 * This is the base class for all export methods. Each data export type (donors, payments, etc) extend this class
6
+	 *
7
+	 * @package     Give
8
+	 * @subpackage  Admin/Reports
9
+	 * @copyright   Copyright (c) 2015, WordImpress
10
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
+	 * @since       1.0
12
+	 */
13 13
 
14 14
 // Exit if accessed directly
15 15
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @return bool Whether we can export or not
38 38
 	 */
39 39
 	public function can_export() {
40
-		return (bool) apply_filters( 'give_export_capability', current_user_can( 'export_give_reports' ) );
40
+		return (bool) apply_filters('give_export_capability', current_user_can('export_give_reports'));
41 41
 	}
42 42
 
43 43
 	/**
@@ -48,16 +48,16 @@  discard block
 block discarded – undo
48 48
 	 * @return void
49 49
 	 */
50 50
 	public function headers() {
51
-		ignore_user_abort( true );
51
+		ignore_user_abort(true);
52 52
 
53
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
54
-			set_time_limit( 0 );
53
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
54
+			set_time_limit(0);
55 55
 		}
56 56
 
57 57
 		nocache_headers();
58
-		header( 'Content-Type: text/csv; charset=utf-8' );
59
-		header( 'Content-Disposition: attachment; filename=give-export-' . $this->export_type . '-' . date( 'm-d-Y' ) . '.csv' );
60
-		header( "Expires: 0" );
58
+		header('Content-Type: text/csv; charset=utf-8');
59
+		header('Content-Disposition: attachment; filename=give-export-'.$this->export_type.'-'.date('m-d-Y').'.csv');
60
+		header("Expires: 0");
61 61
 	}
62 62
 
63 63
 	/**
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function csv_cols() {
71 71
 		$cols = array(
72
-			'id'   => __( 'ID', 'give' ),
73
-			'date' => __( 'Date', 'give' )
72
+			'id'   => __('ID', 'give'),
73
+			'date' => __('Date', 'give')
74 74
 		);
75 75
 
76 76
 		return $cols;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	public function get_csv_cols() {
87 87
 		$cols = $this->csv_cols();
88 88
 
89
-		return apply_filters( 'give_export_csv_cols_' . $this->export_type, $cols );
89
+		return apply_filters('give_export_csv_cols_'.$this->export_type, $cols);
90 90
 	}
91 91
 
92 92
 	/**
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 	public function csv_cols_out() {
101 101
 		$cols = $this->get_csv_cols();
102 102
 		$i    = 1;
103
-		foreach ( $cols as $col_id => $column ) {
104
-			echo '"' . addslashes( $column ) . '"';
105
-			echo $i == count( $cols ) ? '' : ',';
106
-			$i ++;
103
+		foreach ($cols as $col_id => $column) {
104
+			echo '"'.addslashes($column).'"';
105
+			echo $i == count($cols) ? '' : ',';
106
+			$i++;
107 107
 		}
108 108
 		echo "\r\n";
109 109
 	}
@@ -120,16 +120,16 @@  discard block
 block discarded – undo
120 120
 		$data = array(
121 121
 			0 => array(
122 122
 				'id'   => '',
123
-				'data' => date( 'F j, Y' )
123
+				'data' => date('F j, Y')
124 124
 			),
125 125
 			1 => array(
126 126
 				'id'   => '',
127
-				'data' => date( 'F j, Y' )
127
+				'data' => date('F j, Y')
128 128
 			)
129 129
 		);
130 130
 
131
-		$data = apply_filters( 'give_export_get_data', $data );
132
-		$data = apply_filters( 'give_export_get_data_' . $this->export_type, $data );
131
+		$data = apply_filters('give_export_get_data', $data);
132
+		$data = apply_filters('give_export_get_data_'.$this->export_type, $data);
133 133
 
134 134
 		return $data;
135 135
 	}
@@ -147,14 +147,14 @@  discard block
 block discarded – undo
147 147
 		$cols = $this->get_csv_cols();
148 148
 
149 149
 		// Output each row
150
-		foreach ( $data as $row ) {
150
+		foreach ($data as $row) {
151 151
 			$i = 1;
152
-			foreach ( $row as $col_id => $column ) {
152
+			foreach ($row as $col_id => $column) {
153 153
 				// Make sure the column is valid
154
-				if ( array_key_exists( $col_id, $cols ) ) {
155
-					echo '"' . addslashes( $column ) . '"';
156
-					echo $i == count( $cols ) ? '' : ',';
157
-					$i ++;
154
+				if (array_key_exists($col_id, $cols)) {
155
+					echo '"'.addslashes($column).'"';
156
+					echo $i == count($cols) ? '' : ',';
157
+					$i++;
158 158
 				}
159 159
 			}
160 160
 			echo "\r\n";
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 	 * @return void
174 174
 	 */
175 175
 	public function export() {
176
-		if ( ! $this->can_export() ) {
177
-			wp_die( __( 'You do not have permission to export data.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
176
+		if ( ! $this->can_export()) {
177
+			wp_die(__('You do not have permission to export data.', 'give'), __('Error', 'give'), array('response' => 403));
178 178
 		}
179 179
 
180 180
 		// Set headers
Please login to merge, or discard this patch.
includes/admin/reporting/class-form-reports-table.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Download Reports Table Class
4
- *
5
- * @package     Give
6
- * @subpackage  Admin/Reports
7
- * @copyright   Copyright (c) 2015, WordImpress
8
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
- * @since       1.0
10
- */
3
+	 * Download Reports Table Class
4
+	 *
5
+	 * @package     Give
6
+	 * @subpackage  Admin/Reports
7
+	 * @copyright   Copyright (c) 2015, WordImpress
8
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+	 * @since       1.0
10
+	 */
11 11
 
12 12
 // Exit if accessed directly
13 13
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 		global $status, $page;
51 51
 
52 52
 		// Set parent defaults
53
-		parent::__construct( array(
54
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
55
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
53
+		parent::__construct(array(
54
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
55
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
56 56
 			'ajax'     => false                        // Does this table support ajax?
57
-		) );
57
+		));
58 58
 
59
-		add_action( 'give_report_view_actions', array( $this, 'category_filter' ) );
59
+		add_action('give_report_view_actions', array($this, 'category_filter'));
60 60
 		$this->query();
61 61
 
62 62
 	}
@@ -72,18 +72,18 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @return string Column Name
74 74
 	 */
75
-	public function column_default( $item, $column_name ) {
76
-		switch ( $column_name ) {
75
+	public function column_default($item, $column_name) {
76
+		switch ($column_name) {
77 77
 			case 'earnings' :
78
-				return give_currency_filter( give_format_amount( $item[ $column_name ] ) );
78
+				return give_currency_filter(give_format_amount($item[$column_name]));
79 79
 			case 'average_sales' :
80
-				return round( $item[ $column_name ] );
80
+				return round($item[$column_name]);
81 81
 			case 'average_earnings' :
82
-				return give_currency_filter( give_format_amount( $item[ $column_name ] ) );
82
+				return give_currency_filter(give_format_amount($item[$column_name]));
83 83
 			case 'details' :
84
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=forms&form-id=' . $item['ID'] ) . '">' . __( 'View Detailed Report', 'give' ) . '</a>';
84
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-reports&view=forms&form-id='.$item['ID']).'">'.__('View Detailed Report', 'give').'</a>';
85 85
 			default:
86
-				return $item[ $column_name ];
86
+				return $item[$column_name];
87 87
 		}
88 88
 	}
89 89
 
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	public function get_columns() {
98 98
 		$columns = array(
99 99
 			'title'            => give_get_forms_label_singular(),
100
-			'sales'            => __( 'Donations', 'give' ),
101
-			'earnings'         => __( 'Income', 'give' ),
102
-			'average_sales'    => __( 'Monthly Average Donations', 'give' ),
103
-			'average_earnings' => __( 'Monthly Average Income', 'give' ),
104
-			'details'          => __( 'Detailed Report', 'give' )
100
+			'sales'            => __('Donations', 'give'),
101
+			'earnings'         => __('Income', 'give'),
102
+			'average_sales'    => __('Monthly Average Donations', 'give'),
103
+			'average_earnings' => __('Monthly Average Income', 'give'),
104
+			'details'          => __('Detailed Report', 'give')
105 105
 		);
106 106
 
107 107
 		return $columns;
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function get_sortable_columns() {
118 118
 		return array(
119
-			'title'    => array( 'title', true ),
120
-			'sales'    => array( 'sales', false ),
121
-			'earnings' => array( 'earnings', false ),
119
+			'title'    => array('title', true),
120
+			'sales'    => array('sales', false),
121
+			'earnings' => array('earnings', false),
122 122
 		);
123 123
 	}
124 124
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @return int Current page number
131 131
 	 */
132 132
 	public function get_paged() {
133
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
133
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
134 134
 	}
135 135
 
136 136
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @return int Category ID
143 143
 	 */
144 144
 	public function get_category() {
145
-		return isset( $_GET['category'] ) ? absint( $_GET['category'] ) : 0;
145
+		return isset($_GET['category']) ? absint($_GET['category']) : 0;
146 146
 	}
147 147
 
148 148
 
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	public function get_total_forms() {
157 157
 		$total  = 0;
158
-		$counts = wp_count_posts( 'give_forms', 'readable' );
159
-		foreach ( $counts as $status => $count ) {
158
+		$counts = wp_count_posts('give_forms', 'readable');
159
+		foreach ($counts as $status => $count) {
160 160
 			$total += $count;
161 161
 		}
162 162
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 * @since  1.0
171 171
 	 * @return void
172 172
 	 */
173
-	public function bulk_actions( $which = '' ) {
173
+	public function bulk_actions($which = '') {
174 174
 		// These aren't really bulk actions but this outputs the markup in the right place
175 175
 		give_report_views();
176 176
 	}
@@ -183,23 +183,23 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @param string $which
185 185
 	 */
186
-	protected function display_tablenav( $which ) {
186
+	protected function display_tablenav($which) {
187 187
 
188
-		if ( 'top' == $which ) {
189
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
188
+		if ('top' == $which) {
189
+			wp_nonce_field('bulk-'.$this->_args['plural']);
190 190
 		}
191 191
 		?>
192
-		<div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
192
+		<div class="tablenav give-clearfix <?php echo esc_attr($which); ?>">
193 193
 
194
-			<h3 class="alignleft reports-earnings-title"><span><?php _e( 'Form Report', 'give' ); ?></span></h3>
194
+			<h3 class="alignleft reports-earnings-title"><span><?php _e('Form Report', 'give'); ?></span></h3>
195 195
 
196 196
 			<div class="alignright tablenav-right">
197 197
 				<div class="actions bulkactions">
198
-					<?php $this->bulk_actions( $which ); ?>
198
+					<?php $this->bulk_actions($which); ?>
199 199
 				</div>
200 200
 				<?php
201
-				$this->extra_tablenav( $which );
202
-				$this->pagination( $which );
201
+				$this->extra_tablenav($which);
202
+				$this->pagination($which);
203 203
 				?>
204 204
 			</div>
205 205
 
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public function category_filter() {
221 221
 
222
-		$categories = get_terms( 'form_category' );
223
-		if ( $categories && ! is_wp_error( $categories ) ) {
224
-			echo Give()->html->category_dropdown( 'category', $this->get_category() );
222
+		$categories = get_terms('form_category');
223
+		if ($categories && ! is_wp_error($categories)) {
224
+			echo Give()->html->category_dropdown('category', $this->get_category());
225 225
 		}
226 226
 	}
227 227
 
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 	 */
236 236
 	public function query() {
237 237
 
238
-		$orderby  = isset( $_GET['orderby'] ) ? $_GET['orderby'] : 'title';
239
-		$order    = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC';
238
+		$orderby  = isset($_GET['orderby']) ? $_GET['orderby'] : 'title';
239
+		$order    = isset($_GET['order']) ? $_GET['order'] : 'DESC';
240 240
 		$category = $this->get_category();
241 241
 
242 242
 		$args = array(
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 			'suppress_filters' => true
250 250
 		);
251 251
 
252
-		if ( ! empty( $category ) ) {
252
+		if ( ! empty($category)) {
253 253
 			$args['tax_query'] = array(
254 254
 				array(
255 255
 					'taxonomy' => 'form_category',
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			);
259 259
 		}
260 260
 
261
-		switch ( $orderby ) :
261
+		switch ($orderby) :
262 262
 			case 'title' :
263 263
 				$args['orderby'] = 'title';
264 264
 				break;
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 				break;
275 275
 		endswitch;
276 276
 
277
-		$args = apply_filters( 'give_form_reports_prepare_items_args', $args, $this );
277
+		$args = apply_filters('give_form_reports_prepare_items_args', $args, $this);
278 278
 
279
-		$this->products = new WP_Query( $args );
279
+		$this->products = new WP_Query($args);
280 280
 
281 281
 	}
282 282
 
@@ -292,15 +292,15 @@  discard block
 block discarded – undo
292 292
 
293 293
 		$give_forms = $this->products->posts;
294 294
 
295
-		if ( $give_forms ) {
296
-			foreach ( $give_forms as $form ) {
295
+		if ($give_forms) {
296
+			foreach ($give_forms as $form) {
297 297
 				$reports_data[] = array(
298 298
 					'ID'               => $form,
299
-					'title'            => get_the_title( $form ),
300
-					'sales'            => give_get_form_sales_stats( $form ),
301
-					'earnings'         => give_get_form_earnings_stats( $form ),
302
-					'average_sales'    => give_get_average_monthly_form_sales( $form ),
303
-					'average_earnings' => give_get_average_monthly_form_earnings( $form )
299
+					'title'            => get_the_title($form),
300
+					'sales'            => give_get_form_sales_stats($form),
301
+					'earnings'         => give_get_form_earnings_stats($form),
302
+					'average_sales'    => give_get_average_monthly_form_sales($form),
303
+					'average_earnings' => give_get_average_monthly_form_earnings($form)
304 304
 				);
305 305
 			}
306 306
 		}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 
329 329
 		$sortable = $this->get_sortable_columns();
330 330
 
331
-		$this->_column_headers = array( $columns, $hidden, $sortable );
331
+		$this->_column_headers = array($columns, $hidden, $sortable);
332 332
 
333 333
 		$data = $this->reports_data();
334 334
 
@@ -336,10 +336,10 @@  discard block
 block discarded – undo
336 336
 
337 337
 		$this->items = $data;
338 338
 
339
-		$this->set_pagination_args( array(
339
+		$this->set_pagination_args(array(
340 340
 				'total_items' => $total_items,
341 341
 				'per_page'    => $this->per_page,
342
-				'total_pages' => ceil( $total_items / $this->per_page )
342
+				'total_pages' => ceil($total_items / $this->per_page)
343 343
 			)
344 344
 		);
345 345
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/class-gateway-error-logs-list-table.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Gateway Error Log View Class
4
- *
5
- * @package     Give
6
- * @subpackage  Admin/Reports
7
- * @copyright   Copyright (c) 2015, WordImpress
8
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
- */
3
+	 * Gateway Error Log View Class
4
+	 *
5
+	 * @package     Give
6
+	 * @subpackage  Admin/Reports
7
+	 * @copyright   Copyright (c) 2015, WordImpress
8
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+	 */
10 10
 
11 11
 // Exit if accessed directly
12 12
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
16 16
 // Load WP_List_Table if not loaded
17
-if ( ! class_exists( 'WP_List_Table' ) ) {
18
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17
+if ( ! class_exists('WP_List_Table')) {
18
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
19 19
 }
20 20
 
21 21
 /**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		global $status, $page;
46 46
 
47 47
 		// Set parent defaults
48
-		parent::__construct( array(
49
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
50
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
48
+		parent::__construct(array(
49
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
50
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
51 51
 			'ajax'     => false                        // Does this table support ajax?
52
-		) );
52
+		));
53 53
 	}
54 54
 
55 55
 	/**
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return string Column Name
65 65
 	 */
66
-	public function column_default( $item, $column_name ) {
67
-		switch ( $column_name ) {
66
+	public function column_default($item, $column_name) {
67
+		switch ($column_name) {
68 68
 			case 'ID' :
69 69
 				return $item['ID_label'];
70 70
 			case 'error' :
71
-				return get_the_title( $item['ID'] ) ? get_the_title( $item['ID'] ) : __( 'Payment Error', 'give' );
71
+				return get_the_title($item['ID']) ? get_the_title($item['ID']) : __('Payment Error', 'give');
72 72
 			default:
73
-				return $item[ $column_name ];
73
+				return $item[$column_name];
74 74
 		}
75 75
 	}
76 76
 
@@ -84,29 +84,29 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @return void
86 86
 	 */
87
-	public function column_message( $item ) {
87
+	public function column_message($item) {
88 88
 
89 89
 		?>
90
-		<a href="#TB_inline?width=640&amp;inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox" title="<?php _e( 'View Log Message', 'give' ); ?> "><?php _e( 'View Log Message', 'give' ); ?></a>
90
+		<a href="#TB_inline?width=640&amp;inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox" title="<?php _e('View Log Message', 'give'); ?> "><?php _e('View Log Message', 'give'); ?></a>
91 91
 		<div id="log-message-<?php echo $item['ID']; ?>" style="display:none;">
92 92
 			<?php
93 93
 
94
-			$log_message = get_post_field( 'post_content', $item['ID'] );
94
+			$log_message = get_post_field('post_content', $item['ID']);
95 95
 
96
-			$serialized  = strpos( $log_message, '{"' );
96
+			$serialized  = strpos($log_message, '{"');
97 97
 
98 98
 			// Check to see if the log message contains serialized information
99
-			if ( $serialized !== false ) {
100
-				$length = strlen( $log_message ) - $serialized;
101
-				$intro  = substr( $log_message, 0, - $length );
102
-				$data   = substr( $log_message, $serialized, strlen( $log_message ) - 1 );
103
-
104
-				echo wpautop( $intro );
105
-				echo wpautop( __( '<strong>Log data:</strong>', 'give' ) );
106
-				echo '<div style="word-wrap: break-word;">' . wpautop( $data ) . '</div>';
99
+			if ($serialized !== false) {
100
+				$length = strlen($log_message) - $serialized;
101
+				$intro  = substr($log_message, 0, - $length);
102
+				$data   = substr($log_message, $serialized, strlen($log_message) - 1);
103
+
104
+				echo wpautop($intro);
105
+				echo wpautop(__('<strong>Log data:</strong>', 'give'));
106
+				echo '<div style="word-wrap: break-word;">'.wpautop($data).'</div>';
107 107
 			} else {
108 108
 				// No serialized data found
109
-				echo wpautop( $log_message );
109
+				echo wpautop($log_message);
110 110
 			}
111 111
 			?>
112 112
 		</div>
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function get_columns() {
124 124
 		$columns = array(
125
-			'ID'         => __( 'Log ID', 'give' ),
126
-			'payment_id' => __( 'Payment ID', 'give' ),
127
-			'error'      => __( 'Error', 'give' ),
128
-			'message'    => __( 'Error Message', 'give' ),
129
-			'gateway'    => __( 'Gateway', 'give' ),
130
-			'date'       => __( 'Date', 'give' )
125
+			'ID'         => __('Log ID', 'give'),
126
+			'payment_id' => __('Payment ID', 'give'),
127
+			'error'      => __('Error', 'give'),
128
+			'message'    => __('Error Message', 'give'),
129
+			'gateway'    => __('Gateway', 'give'),
130
+			'date'       => __('Date', 'give')
131 131
 		);
132 132
 
133 133
 		return $columns;
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @return int Current page number
142 142
 	 */
143 143
 	public function get_paged() {
144
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
144
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
145 145
 	}
146 146
 
147 147
 	/**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @since  1.0
152 152
 	 * @return void
153 153
 	 */
154
-	public function bulk_actions( $which = '' ) {
154
+	public function bulk_actions($which = '') {
155 155
 		// These aren't really bulk actions but this outputs the markup in the right place
156 156
 		give_log_views();
157 157
 	}
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		global $give_logs;
169 169
 
170 170
 		// Prevent the queries from getting cached. Without this there are occasional memory issues for some installs
171
-		wp_suspend_cache_addition( true );
171
+		wp_suspend_cache_addition(true);
172 172
 
173 173
 		$logs_data = array();
174 174
 		$paged     = $this->get_paged();
@@ -177,17 +177,17 @@  discard block
 block discarded – undo
177 177
 			'paged'    => $paged
178 178
 		);
179 179
 
180
-		$logs = $give_logs->get_connected_logs( $log_query );
180
+		$logs = $give_logs->get_connected_logs($log_query);
181 181
 
182
-		if ( $logs ) {
183
-			foreach ( $logs as $log ) {
182
+		if ($logs) {
183
+			foreach ($logs as $log) {
184 184
 
185 185
 				$logs_data[] = array(
186 186
 					'ID'         => $log->ID,
187
-					'ID_label'   => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>',
187
+					'ID_label'   => '<span class=\'give-item-label give-item-label-gray\'>'.$log->ID.'</span>',
188 188
 					'payment_id' => $log->post_parent,
189 189
 					'error'      => 'error',
190
-					'gateway'    => give_get_payment_gateway( $log->post_parent ),
190
+					'gateway'    => give_get_payment_gateway($log->post_parent),
191 191
 					'date'       => $log->post_date
192 192
 				);
193 193
 			}
@@ -215,15 +215,15 @@  discard block
 block discarded – undo
215 215
 		$columns               = $this->get_columns();
216 216
 		$hidden                = array(); // No hidden columns
217 217
 		$sortable              = $this->get_sortable_columns();
218
-		$this->_column_headers = array( $columns, $hidden, $sortable );
218
+		$this->_column_headers = array($columns, $hidden, $sortable);
219 219
 		$current_page          = $this->get_pagenum();
220 220
 		$this->items           = $this->get_logs();
221
-		$total_items           = $give_logs->get_log_count( 0, 'gateway_error' );
221
+		$total_items           = $give_logs->get_log_count(0, 'gateway_error');
222 222
 
223
-		$this->set_pagination_args( array(
223
+		$this->set_pagination_args(array(
224 224
 				'total_items' => $total_items,
225 225
 				'per_page'    => $this->per_page,
226
-				'total_pages' => ceil( $total_items / $this->per_page )
226
+				'total_pages' => ceil($total_items / $this->per_page)
227 227
 			)
228 228
 		);
229 229
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/class-gateways-reports-table.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Gateways Reports Table Class
4
- *
5
- * @package     Give
6
- * @subpackage  Admin/Reports
7
- * @copyright   Copyright (c) 2015, WordImpress
8
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
- * @since       1.5
10
- */
3
+	 * Gateways Reports Table Class
4
+	 *
5
+	 * @package     Give
6
+	 * @subpackage  Admin/Reports
7
+	 * @copyright   Copyright (c) 2015, WordImpress
8
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+	 * @since       1.5
10
+	 */
11 11
 
12 12
 // Exit if accessed directly
13 13
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		global $status, $page;
46 46
 
47 47
 		// Set parent defaults
48
-		parent::__construct( array(
49
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
50
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
48
+		parent::__construct(array(
49
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
50
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
51 51
 			'ajax'     => false                        // Does this table support ajax?
52
-		) );
52
+		));
53 53
 
54 54
 	}
55 55
 
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
68
-		switch ( $column_name ) {
67
+	public function column_default($item, $column_name) {
68
+		switch ($column_name) {
69 69
 			default:
70
-				return $item[ $column_name ];
70
+				return $item[$column_name];
71 71
 		}
72 72
 	}
73 73
 
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function get_columns() {
82 82
 		$columns = array(
83
-			'label'          => __( 'Gateway', 'give' ),
84
-			'complete_sales' => __( 'Complete Sales', 'give' ),
85
-			'pending_sales'  => __( 'Pending / Failed Sales', 'give' ),
86
-			'total_sales'    => __( 'Total Sales', 'give' )
83
+			'label'          => __('Gateway', 'give'),
84
+			'complete_sales' => __('Complete Sales', 'give'),
85
+			'pending_sales'  => __('Pending / Failed Sales', 'give'),
86
+			'total_sales'    => __('Total Sales', 'give')
87 87
 		);
88 88
 
89 89
 		return $columns;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 * @return int Current page number
99 99
 	 */
100 100
 	public function get_paged() {
101
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
101
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
102 102
 	}
103 103
 
104 104
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @since  1.5
110 110
 	 * @return void
111 111
 	 */
112
-	public function bulk_actions( $which = '' ) {
112
+	public function bulk_actions($which = '') {
113 113
 		// These aren't really bulk actions but this outputs the markup in the right place
114 114
 		give_report_views();
115 115
 	}
@@ -122,25 +122,25 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @param string $which
124 124
 	 */
125
-	protected function display_tablenav( $which ) {
125
+	protected function display_tablenav($which) {
126 126
 
127
-		if ( 'top' == $which ) {
128
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
127
+		if ('top' == $which) {
128
+			wp_nonce_field('bulk-'.$this->_args['plural']);
129 129
 		}
130 130
 		?>
131
-		<div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
131
+		<div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr($which); ?>">
132 132
 
133
-			<h3 class="alignleft reports-earnings-title"><span><?php _e( 'Payment Methods Report', 'give' ); ?></span></h3>
133
+			<h3 class="alignleft reports-earnings-title"><span><?php _e('Payment Methods Report', 'give'); ?></span></h3>
134 134
 
135 135
 			<div class="alignright tablenav-right">
136 136
 				<div class="actions bulkactions">
137 137
 					<?php
138
-					$this->bulk_actions( $which ); ?>
138
+					$this->bulk_actions($which); ?>
139 139
 
140 140
 				</div>
141 141
 				<?php
142
-				$this->extra_tablenav( $which );
143
-				$this->pagination( $which );
142
+				$this->extra_tablenav($which);
143
+				$this->pagination($which);
144 144
 				?>
145 145
 			</div>
146 146
 
@@ -164,17 +164,17 @@  discard block
 block discarded – undo
164 164
 		$reports_data = array();
165 165
 		$gateways     = give_get_payment_gateways();
166 166
 
167
-		foreach ( $gateways as $gateway_id => $gateway ) {
167
+		foreach ($gateways as $gateway_id => $gateway) {
168 168
 
169
-			$complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' );
170
-			$pending_count  = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) );
169
+			$complete_count = give_count_sales_by_gateway($gateway_id, 'publish');
170
+			$pending_count  = give_count_sales_by_gateway($gateway_id, array('pending', 'failed'));
171 171
 
172 172
 			$reports_data[] = array(
173 173
 				'ID'             => $gateway_id,
174 174
 				'label'          => $gateway['admin_label'],
175
-				'complete_sales' => give_format_amount( $complete_count, false ),
176
-				'pending_sales'  => give_format_amount( $pending_count, false ),
177
-				'total_sales'    => give_format_amount( $complete_count + $pending_count, false )
175
+				'complete_sales' => give_format_amount($complete_count, false),
176
+				'pending_sales'  => give_format_amount($pending_count, false),
177
+				'total_sales'    => give_format_amount($complete_count + $pending_count, false)
178 178
 			);
179 179
 		}
180 180
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 		$columns               = $this->get_columns();
197 197
 		$hidden                = array(); // No hidden columns
198 198
 		$sortable              = $this->get_sortable_columns();
199
-		$this->_column_headers = array( $columns, $hidden, $sortable );
199
+		$this->_column_headers = array($columns, $hidden, $sortable);
200 200
 		$this->items           = $this->reports_data();
201 201
 
202 202
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/class-give-graph.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Graphs
4
- *
5
- * This class handles building pretty report graphs
6
- *
7
- * @package     Give
8
- * @subpackage  Admin/Reports
9
- * @copyright   Copyright (c) 2012, WordImpress
10
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
- * @since       1.0
12
- */
3
+	 * Graphs
4
+	 *
5
+	 * This class handles building pretty report graphs
6
+	 *
7
+	 * @package     Give
8
+	 * @subpackage  Admin/Reports
9
+	 * @copyright   Copyright (c) 2012, WordImpress
10
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
+	 * @since       1.0
12
+	 */
13 13
 
14 14
 // Exit if accessed directly
15 15
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @since 1.0
80 80
 	 */
81
-	public function __construct( $_data ) {
81
+	public function __construct($_data) {
82 82
 
83 83
 		$this->data = $_data;
84 84
 
85 85
 		// Generate unique ID
86
-		$this->id = md5( rand() );
86
+		$this->id = md5(rand());
87 87
 
88 88
 		// Setup default options;
89
-		$this->options = apply_filters( 'give_graph_args', array(
89
+		$this->options = apply_filters('give_graph_args', array(
90 90
 			'y_mode'          => null,
91 91
 			'x_mode'          => null,
92 92
 			'y_decimals'      => 0,
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 			'bars'            => true,
104 104
 			'lines'           => false,
105 105
 			'points'          => true
106
-		) );
106
+		));
107 107
 
108 108
 	}
109 109
 
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @since 1.0
117 117
 	 */
118
-	public function set( $key, $value ) {
119
-		$this->options[ $key ] = $value;
118
+	public function set($key, $value) {
119
+		$this->options[$key] = $value;
120 120
 	}
121 121
 
122 122
 	/**
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @since 1.0
128 128
 	 */
129
-	public function get( $key ) {
130
-		return isset( $this->options[ $key ] ) ? $this->options[ $key ] : false;
129
+	public function get($key) {
130
+		return isset($this->options[$key]) ? $this->options[$key] : false;
131 131
 	}
132 132
 
133 133
 	/**
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * @since 1.0
137 137
 	 */
138 138
 	public function get_data() {
139
-		return apply_filters( 'give_get_graph_data', $this->data, $this );
139
+		return apply_filters('give_get_graph_data', $this->data, $this);
140 140
 	}
141 141
 
142 142
 	/**
@@ -146,19 +146,19 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	public function load_scripts() {
148 148
 		// Use minified libraries if SCRIPT_DEBUG is turned off
149
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
149
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
150 150
 
151
-		wp_register_script( 'jquery-flot-orderbars', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.orderBars' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
152
-		wp_enqueue_script( 'jquery-flot-orderbars' );
151
+		wp_register_script('jquery-flot-orderbars', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.orderBars'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
152
+		wp_enqueue_script('jquery-flot-orderbars');
153 153
 
154
-		wp_register_script( 'jquery-flot-time', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.time' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
155
-		wp_enqueue_script( 'jquery-flot-time' );
154
+		wp_register_script('jquery-flot-time', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.time'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
155
+		wp_enqueue_script('jquery-flot-time');
156 156
 
157
-		wp_register_script( 'jquery-flot-resize', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot.resize' . $suffix . '.js', array('jquery-flot'), GIVE_VERSION );
158
-		wp_enqueue_script( 'jquery-flot-resize' );
157
+		wp_register_script('jquery-flot-resize', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot.resize'.$suffix.'.js', array('jquery-flot'), GIVE_VERSION);
158
+		wp_enqueue_script('jquery-flot-resize');
159 159
 
160
-		wp_register_script( 'jquery-flot', GIVE_PLUGIN_URL . 'assets/js/plugins/jquery.flot' . $suffix . '.js', false, GIVE_VERSION );
161
-		wp_enqueue_script( 'jquery-flot' );
160
+		wp_register_script('jquery-flot', GIVE_PLUGIN_URL.'assets/js/plugins/jquery.flot'.$suffix.'.js', false, GIVE_VERSION);
161
+		wp_enqueue_script('jquery-flot');
162 162
 
163 163
 	}
164 164
 
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
 					[
186 186
 						<?php
187 187
 							$order = 0;
188
-							foreach( $this->get_data() as $label => $data ) :
188
+							foreach ($this->get_data() as $label => $data) :
189 189
 						?>
190 190
 						{
191
-							label : "<?php echo esc_attr( $label ); ?>",
192
-							id    : "<?php echo sanitize_key( $label ); ?>",
191
+							label : "<?php echo esc_attr($label); ?>",
192
+							id    : "<?php echo sanitize_key($label); ?>",
193 193
 							// data format is: [ point on x, value on y ]
194
-							data  : [<?php foreach( $data as $point ) { echo '[' . implode( ',', $point ) . '],'; } ?>],
194
+							data  : [<?php foreach ($data as $point) { echo '['.implode(',', $point).'],'; } ?>],
195 195
 							points: {
196 196
 								show: <?php echo $this->options['points'] ? 'true' : 'false'; ?>,
197 197
 							},
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 								fill     : true,
207 207
 								fillColor: {colors: [{opacity: 0.4}, {opacity: 0.1}]}
208 208
 							},
209
-							<?php if( $this->options[ 'multiple_y_axes' ] ) : ?>
209
+							<?php if ($this->options['multiple_y_axes']) : ?>
210 210
 							yaxis : <?php echo $yaxis_count; ?>
211 211
 							<?php endif; ?>
212 212
 
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
 						grid: {
221 221
 							show           : true,
222 222
 							aboveData      : false,
223
-							color          : "<?php echo $this->options[ 'color' ]; ?>",
224
-							backgroundColor: "<?php echo $this->options[ 'bgcolor' ]; ?>",
225
-							borderColor    : "<?php echo $this->options[ 'bordercolor' ]; ?>",
226
-							borderWidth    : <?php echo absint( $this->options[ 'borderwidth' ] ); ?>,
223
+							color          : "<?php echo $this->options['color']; ?>",
224
+							backgroundColor: "<?php echo $this->options['bgcolor']; ?>",
225
+							borderColor    : "<?php echo $this->options['bordercolor']; ?>",
226
+							borderWidth    : <?php echo absint($this->options['borderwidth']); ?>,
227 227
 							clickable      : false,
228 228
 							hoverable      : true
229 229
 						},
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 							mode        : "<?php echo $this->options['x_mode']; ?>",
235 235
 							timeFormat  : "<?php echo $this->options['x_mode'] == 'time' ? $this->options['time_format'] : ''; ?>",
236 236
 							tickSize    : "<?php echo $this->options['x_mode'] == 'time' ? '' : 1; ?>",
237
-							<?php if( $this->options['x_mode'] != 'time' ) : ?>
237
+							<?php if ($this->options['x_mode'] != 'time') : ?>
238 238
 							tickDecimals: <?php echo $this->options['x_decimals']; ?>
239 239
 							<?php endif; ?>
240 240
 						},
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 							min         : 0,
244 244
 							mode        : "<?php echo $this->options['y_mode']; ?>",
245 245
 							timeFormat  : "<?php echo $this->options['y_mode'] == 'time' ? $this->options['time_format'] : ''; ?>",
246
-							<?php if( $this->options['y_mode'] != 'time' ) : ?>
246
+							<?php if ($this->options['y_mode'] != 'time') : ?>
247 247
 							tickDecimals: <?php echo $this->options['y_decimals']; ?>
248 248
 							<?php endif; ?>
249 249
 						}
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 	 * @since 1.0
304 304
 	 */
305 305
 	public function display() {
306
-		do_action( 'give_before_graph', $this );
306
+		do_action('give_before_graph', $this);
307 307
 		echo $this->build_graph();
308
-		do_action( 'give_after_graph', $this );
308
+		do_action('give_after_graph', $this);
309 309
 	}
310 310
 
311 311
 }
Please login to merge, or discard this patch.
includes/admin/reporting/logs.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @return void
24 24
  */
25 25
 function give_logs_view_sales() {
26
-	include( dirname( __FILE__ ) . '/class-sales-logs-list-table.php' );
26
+	include(dirname(__FILE__).'/class-sales-logs-list-table.php');
27 27
 
28 28
 	$logs_table = new Give_Sales_Log_Table();
29 29
 	$logs_table->prepare_items();
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 }
33 33
 
34
-add_action( 'give_logs_view_sales', 'give_logs_view_sales' );
34
+add_action('give_logs_view_sales', 'give_logs_view_sales');
35 35
 
36 36
 
37 37
 /**
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
  * @return void
44 44
  */
45 45
 function give_logs_view_gateway_errors() {
46
-	include( dirname( __FILE__ ) . '/class-gateway-error-logs-list-table.php' );
46
+	include(dirname(__FILE__).'/class-gateway-error-logs-list-table.php');
47 47
 
48 48
 	$logs_table = new Give_Gateway_Error_Log_Table();
49 49
 	$logs_table->prepare_items();
50 50
 	$logs_table->display();
51 51
 }
52 52
 
53
-add_action( 'give_logs_view_gateway_errors', 'give_logs_view_gateway_errors' );
53
+add_action('give_logs_view_gateway_errors', 'give_logs_view_gateway_errors');
54 54
 
55 55
 /**
56 56
  * API Request Logs
@@ -62,28 +62,28 @@  discard block
 block discarded – undo
62 62
  * @return void
63 63
  */
64 64
 function give_logs_view_api_requests() {
65
-	include( dirname( __FILE__ ) . '/class-api-requests-logs-list-table.php' );
65
+	include(dirname(__FILE__).'/class-api-requests-logs-list-table.php');
66 66
 
67 67
 	$logs_table = new Give_API_Request_Log_Table();
68 68
 	$logs_table->prepare_items();
69 69
 	?>
70 70
 	<div class="wrap">
71
-		<?php do_action( 'give_logs_api_requests_top' ); ?>
72
-		<form id="give-logs-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=logs' ); ?>">
71
+		<?php do_action('give_logs_api_requests_top'); ?>
72
+		<form id="give-logs-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-reports&tab=logs'); ?>">
73 73
 			<?php
74
-			$logs_table->search_box( __( 'Search', 'give' ), 'give-api-requests' );
74
+			$logs_table->search_box(__('Search', 'give'), 'give-api-requests');
75 75
 			$logs_table->display();
76 76
 			?>
77 77
 			<input type="hidden" name="post_type" value="give_forms" />
78 78
 			<input type="hidden" name="page" value="give-reports" />
79 79
 			<input type="hidden" name="tab" value="logs" />
80 80
 		</form>
81
-		<?php do_action( 'give_logs_api_requests_bottom' ); ?>
81
+		<?php do_action('give_logs_api_requests_bottom'); ?>
82 82
 	</div>
83 83
 <?php
84 84
 }
85 85
 
86
-add_action( 'give_logs_view_api_requests', 'give_logs_view_api_requests' );
86
+add_action('give_logs_view_api_requests', 'give_logs_view_api_requests');
87 87
 
88 88
 
89 89
 /**
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
  */
95 95
 function give_log_default_views() {
96 96
 	$views = array(
97
-		'sales'          => __( 'Donations', 'give' ),
98
-		'gateway_errors' => __( 'Payment Errors', 'give' ),
99
-		'api_requests'   => __( 'API Requests', 'give' )
97
+		'sales'          => __('Donations', 'give'),
98
+		'gateway_errors' => __('Payment Errors', 'give'),
99
+		'api_requests'   => __('API Requests', 'give')
100 100
 	);
101 101
 
102
-	$views = apply_filters( 'give_log_views', $views );
102
+	$views = apply_filters('give_log_views', $views);
103 103
 
104 104
 	return $views;
105 105
 }
@@ -112,23 +112,23 @@  discard block
 block discarded – undo
112 112
  */
113 113
 function give_log_views() {
114 114
 	$views        = give_log_default_views();
115
-	$current_view = isset( $_GET['view'] ) && array_key_exists( $_GET['view'], give_log_default_views() ) ? sanitize_text_field( $_GET['view'] ) : 'sales';
115
+	$current_view = isset($_GET['view']) && array_key_exists($_GET['view'], give_log_default_views()) ? sanitize_text_field($_GET['view']) : 'sales';
116 116
 	?>
117 117
 	<form id="give-logs-filter" method="get" action="edit.php">
118 118
 		<select id="give-logs-view" name="view">
119
-			<option value="-1"><?php _e( 'Log Type', 'give' ); ?></option>
120
-			<?php foreach ( $views as $view_id => $label ): ?>
121
-				<option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option>
119
+			<option value="-1"><?php _e('Log Type', 'give'); ?></option>
120
+			<?php foreach ($views as $view_id => $label): ?>
121
+				<option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option>
122 122
 			<?php endforeach; ?>
123 123
 		</select>
124 124
 
125
-		<?php do_action( 'give_log_view_actions' ); ?>
125
+		<?php do_action('give_log_view_actions'); ?>
126 126
 
127 127
 		<input type="hidden" name="post_type" value="give_forms" />
128 128
 		<input type="hidden" name="page" value="give-reports" />
129 129
 		<input type="hidden" name="tab" value="logs" />
130 130
 
131
-		<?php submit_button( __( 'Apply', 'give' ), 'secondary', 'submit', false ); ?>
131
+		<?php submit_button(__('Apply', 'give'), 'secondary', 'submit', false); ?>
132 132
 	</form>
133 133
 <?php
134 134
 }
135 135
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/reporting/pdf-reports.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * PDF Report Generation Functions
4
- *
5
- * @package     Give
6
- * @subpackage  Admin/Reports
7
- * @copyright   Copyright (c) 2015, WordImpress
8
- * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
- * @since       1.0
10
- */
3
+	 * PDF Report Generation Functions
4
+	 *
5
+	 * @package     Give
6
+	 * @subpackage  Admin/Reports
7
+	 * @copyright   Copyright (c) 2015, WordImpress
8
+	 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+	 * @since       1.0
10
+	 */
11 11
 
12 12
 // Exit if accessed directly
13 13
 if ( ! defined( 'ABSPATH' ) ) {
Please login to merge, or discard this patch.
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -25,75 +25,75 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * @uses   give_pdf
27 27
  */
28
-function give_generate_pdf( $data ) {
28
+function give_generate_pdf($data) {
29 29
 
30
-	if ( ! current_user_can( 'view_give_reports' ) ) {
31
-		wp_die( __( 'You do not have permission to generate PDF sales reports', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
30
+	if ( ! current_user_can('view_give_reports')) {
31
+		wp_die(__('You do not have permission to generate PDF sales reports', 'give'), __('Error', 'give'), array('response' => 403));
32 32
 	}
33 33
 
34
-	if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) {
35
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
34
+	if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) {
35
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array('response' => 403));
36 36
 	}
37 37
 
38
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php';
39
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/fpdf/give_pdf.php';
38
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/fpdf.php';
39
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/fpdf/give_pdf.php';
40 40
 
41
-	$daterange = date_i18n( get_option( 'date_format' ), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ) . ' ' . utf8_decode( __( 'to', 'give' ) ) . ' ' . date_i18n( get_option( 'date_format' ) );
41
+	$daterange = date_i18n(get_option('date_format'), mktime(0, 0, 0, 1, 1, date('Y'))).' '.utf8_decode(__('to', 'give')).' '.date_i18n(get_option('date_format'));
42 42
 
43 43
 	$pdf = new give_pdf();
44
-	$pdf->AddPage( 'L', 'A4' );
44
+	$pdf->AddPage('L', 'A4');
45 45
 
46
-	$pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) );
47
-	$pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) );
48
-	$pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) );
46
+	$pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give')));
47
+	$pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give')));
48
+	$pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give')));
49 49
 
50
-	$pdf->Image( GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png', 247, 8 );
50
+	$pdf->Image(GIVE_PLUGIN_URL.'assets/images/give-logo-small.png', 247, 8);
51 51
 
52
-	$pdf->SetMargins( 8, 8, 8 );
53
-	$pdf->SetX( 8 );
52
+	$pdf->SetMargins(8, 8, 8);
53
+	$pdf->SetX(8);
54 54
 
55
-	$pdf->SetFont( 'Helvetica', '', 16 );
56
-	$pdf->SetTextColor( 50, 50, 50 );
57
-	$pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false );
55
+	$pdf->SetFont('Helvetica', '', 16);
56
+	$pdf->SetTextColor(50, 50, 50);
57
+	$pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false);
58 58
 
59
-	$pdf->SetFont( 'Helvetica', '', 13 );
59
+	$pdf->SetFont('Helvetica', '', 13);
60 60
 	$pdf->Ln();
61
-	$pdf->SetTextColor( 150, 150, 150 );
62
-	$pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false );
61
+	$pdf->SetTextColor(150, 150, 150);
62
+	$pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false);
63 63
 	$pdf->Ln();
64
-	$pdf->SetTextColor( 50, 50, 50 );
65
-	$pdf->SetFont( 'Helvetica', '', 14 );
66
-	$pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false );
67
-	$pdf->SetFont( 'Helvetica', '', 12 );
64
+	$pdf->SetTextColor(50, 50, 50);
65
+	$pdf->SetFont('Helvetica', '', 14);
66
+	$pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false);
67
+	$pdf->SetFont('Helvetica', '', 12);
68 68
 
69
-	$pdf->SetFillColor( 238, 238, 238 );
70
-	$pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true );
71
-	$pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true );
72
-	$pdf->Cell( 50, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true );
73
-	$pdf->Cell( 50, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true );
74
-	$pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true );
75
-	$pdf->Cell( 35, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true );
69
+	$pdf->SetFillColor(238, 238, 238);
70
+	$pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true);
71
+	$pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true);
72
+	$pdf->Cell(50, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true);
73
+	$pdf->Cell(50, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true);
74
+	$pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true);
75
+	$pdf->Cell(35, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true);
76 76
 
77
-	$year       = date( 'Y' );
78
-	$give_forms = get_posts( array( 'post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => - 1 ) );
77
+	$year       = date('Y');
78
+	$give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1));
79 79
 
80
-	if ( $give_forms ):
81
-		$pdf->SetWidths( array( 70, 30, 50, 50, 45, 35 ) );
80
+	if ($give_forms):
81
+		$pdf->SetWidths(array(70, 30, 50, 50, 45, 35));
82 82
 
83
-		foreach ( $give_forms as $form ):
84
-			$pdf->SetFillColor( 255, 255, 255 );
83
+		foreach ($give_forms as $form):
84
+			$pdf->SetFillColor(255, 255, 255);
85 85
 
86 86
 			$title = $form->post_title;
87 87
 
88
-			if ( give_has_variable_prices( $form->ID ) ) {
88
+			if (give_has_variable_prices($form->ID)) {
89 89
 
90
-				$prices = give_get_variable_prices( $form->ID );
90
+				$prices = give_get_variable_prices($form->ID);
91 91
 
92 92
 				$first = $prices[0]['_give_amount'];
93
-				$last  = array_pop( $prices );
93
+				$last  = array_pop($prices);
94 94
 				$last  = $last['_give_amount'];
95 95
 
96
-				if ( $first < $last ) {
96
+				if ($first < $last) {
97 97
 					$min = $first;
98 98
 					$max = $last;
99 99
 				} else {
@@ -101,51 +101,51 @@  discard block
 block discarded – undo
101 101
 					$max = $first;
102 102
 				}
103 103
 
104
-				$price = html_entity_decode( give_currency_filter( give_format_amount( $min ) ) . ' - ' . give_currency_filter( give_format_amount( $max ) ) );
104
+				$price = html_entity_decode(give_currency_filter(give_format_amount($min)).' - '.give_currency_filter(give_format_amount($max)));
105 105
 			} else {
106
-				$price = html_entity_decode( give_currency_filter( give_get_form_price( $form->ID ) ) );
106
+				$price = html_entity_decode(give_currency_filter(give_get_form_price($form->ID)));
107 107
 			}
108 108
 
109
-			$categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' );
110
-			$categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : '';
109
+			$categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', '');
110
+			$categories = ! is_wp_error($categories) ? strip_tags($categories) : '';
111 111
 
112
-			$tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' );
113
-			$tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : '';
112
+			$tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', '');
113
+			$tags = ! is_wp_error($tags) ? strip_tags($tags) : '';
114 114
 
115
-			$sales    = give_get_form_sales_stats( $form->ID );
116
-			$link     = get_permalink( $form->ID );
117
-			$earnings = html_entity_decode( give_currency_filter( give_get_form_earnings_stats( $form->ID ) ) );
115
+			$sales    = give_get_form_sales_stats($form->ID);
116
+			$link     = get_permalink($form->ID);
117
+			$earnings = html_entity_decode(give_currency_filter(give_get_form_earnings_stats($form->ID)));
118 118
 
119
-			if ( function_exists( 'iconv' ) ) {
119
+			if (function_exists('iconv')) {
120 120
 				// Ensure characters like euro; are properly converted.
121
-				$price    = iconv( 'UTF-8', 'windows-1252', utf8_encode( $price ) );
122
-				$earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) );
121
+				$price    = iconv('UTF-8', 'windows-1252', utf8_encode($price));
122
+				$earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings));
123 123
 			}
124 124
 
125
-			$pdf->Row( array( $title, $price, $categories, $tags, $sales, $earnings ) );
125
+			$pdf->Row(array($title, $price, $categories, $tags, $sales, $earnings));
126 126
 		endforeach;
127 127
 	else:
128
-		$pdf->SetWidths( array( 280 ) );
129
-		$title = utf8_decode( sprintf( __( 'No %s found.', 'give' ), give_get_forms_label_plural() ) );
130
-		$pdf->Row( array( $title ) );
128
+		$pdf->SetWidths(array(280));
129
+		$title = utf8_decode(sprintf(__('No %s found.', 'give'), give_get_forms_label_plural()));
130
+		$pdf->Row(array($title));
131 131
 	endif;
132 132
 
133 133
 	$pdf->Ln();
134
-	$pdf->SetTextColor( 50, 50, 50 );
135
-	$pdf->SetFont( 'Helvetica', '', 14 );
136
-	$pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false );
137
-	$pdf->SetFont( 'Helvetica', '', 12 );
138
-
139
-	$image = html_entity_decode( urldecode( give_draw_chart_image() ) );
140
-	$image = str_replace( ' ', '%20', $image );
141
-
142
-	$pdf->SetX( 25 );
143
-	$pdf->Image( $image . '&file=.png' );
144
-	$pdf->Ln( 7 );
145
-	$pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' );
134
+	$pdf->SetTextColor(50, 50, 50);
135
+	$pdf->SetFont('Helvetica', '', 14);
136
+	$pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false);
137
+	$pdf->SetFont('Helvetica', '', 12);
138
+
139
+	$image = html_entity_decode(urldecode(give_draw_chart_image()));
140
+	$image = str_replace(' ', '%20', $image);
141
+
142
+	$pdf->SetX(25);
143
+	$pdf->Image($image.'&file=.png');
144
+	$pdf->Ln(7);
145
+	$pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D');
146 146
 }
147 147
 
148
-add_action( 'give_generate_pdf', 'give_generate_pdf' );
148
+add_action('give_generate_pdf', 'give_generate_pdf');
149 149
 
150 150
 /**
151 151
  * Draws Chart for PDF Report
@@ -162,38 +162,38 @@  discard block
 block discarded – undo
162 162
  * @return string $chart->getUrl() URL for the Google Chart
163 163
  */
164 164
 function give_draw_chart_image() {
165
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php';
166
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php';
167
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php';
165
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php';
166
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php';
167
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php';
168 168
 
169
-	$chart = new GoogleChart( 'lc', 900, 330 );
169
+	$chart = new GoogleChart('lc', 900, 330);
170 170
 
171 171
 	$i        = 1;
172 172
 	$earnings = "";
173 173
 	$sales    = "";
174 174
 
175
-	while ( $i <= 12 ) :
176
-		$earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ",";
177
-		$sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ",";
178
-		$i ++;
175
+	while ($i <= 12) :
176
+		$earnings .= give_get_earnings_by_date(null, $i, date('Y')).",";
177
+		$sales .= give_get_sales_by_date(null, $i, date('Y')).",";
178
+		$i++;
179 179
 	endwhile;
180 180
 
181
-	$earnings_array = explode( ",", $earnings );
182
-	$sales_array    = explode( ",", $sales );
181
+	$earnings_array = explode(",", $earnings);
182
+	$sales_array    = explode(",", $sales);
183 183
 
184 184
 	$i = 0;
185
-	while ( $i <= 11 ) {
186
-		if ( empty( $sales_array[ $i ] ) ) {
187
-			$sales_array[ $i ] = 0;
185
+	while ($i <= 11) {
186
+		if (empty($sales_array[$i])) {
187
+			$sales_array[$i] = 0;
188 188
 		}
189
-		$i ++;
189
+		$i++;
190 190
 	}
191 191
 
192 192
 	$min_earnings   = 0;
193
-	$max_earnings   = max( $earnings_array );
194
-	$earnings_scale = round( $max_earnings, - 1 );
193
+	$max_earnings   = max($earnings_array);
194
+	$earnings_scale = round($max_earnings, - 1);
195 195
 
196
-	$data = new GoogleChartData( array(
196
+	$data = new GoogleChartData(array(
197 197
 		$earnings_array[0],
198 198
 		$earnings_array[1],
199 199
 		$earnings_array[2],
@@ -206,25 +206,25 @@  discard block
 block discarded – undo
206 206
 		$earnings_array[9],
207 207
 		$earnings_array[10],
208 208
 		$earnings_array[11]
209
-	) );
209
+	));
210 210
 
211
-	$data->setLegend( __( 'Income', 'give' ) );
212
-	$data->setColor( '1b58a3' );
213
-	$chart->addData( $data );
211
+	$data->setLegend(__('Income', 'give'));
212
+	$data->setColor('1b58a3');
213
+	$chart->addData($data);
214 214
 
215
-	$shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE );
216
-	$shape_marker->setColor( '000000' );
217
-	$shape_marker->setSize( 7 );
218
-	$shape_marker->setBorder( 2 );
219
-	$shape_marker->setData( $data );
220
-	$chart->addMarker( $shape_marker );
215
+	$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
216
+	$shape_marker->setColor('000000');
217
+	$shape_marker->setSize(7);
218
+	$shape_marker->setBorder(2);
219
+	$shape_marker->setData($data);
220
+	$chart->addMarker($shape_marker);
221 221
 
222
-	$value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE );
223
-	$value_marker->setColor( '000000' );
224
-	$value_marker->setData( $data );
225
-	$chart->addMarker( $value_marker );
222
+	$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
223
+	$value_marker->setColor('000000');
224
+	$value_marker->setData($data);
225
+	$chart->addMarker($value_marker);
226 226
 
227
-	$data = new GoogleChartData( array(
227
+	$data = new GoogleChartData(array(
228 228
 		$sales_array[0],
229 229
 		$sales_array[1],
230 230
 		$sales_array[2],
@@ -237,46 +237,46 @@  discard block
 block discarded – undo
237 237
 		$sales_array[9],
238 238
 		$sales_array[10],
239 239
 		$sales_array[11]
240
-	) );
241
-	$data->setLegend( __( 'Donations', 'give' ) );
242
-	$data->setColor( 'ff6c1c' );
243
-	$chart->addData( $data );
244
-
245
-	$chart->setTitle( __( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 );
246
-
247
-	$chart->setScale( 0, $max_earnings );
248
-
249
-	$y_axis = new GoogleChartAxis( 'y' );
250
-	$y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) );
251
-	$chart->addAxis( $y_axis );
252
-
253
-	$x_axis = new GoogleChartAxis( 'x' );
254
-	$x_axis->setTickMarks( 5 );
255
-	$x_axis->setLabels( array(
256
-		__( 'Jan', 'give' ),
257
-		__( 'Feb', 'give' ),
258
-		__( 'Mar', 'give' ),
259
-		__( 'Apr', 'give' ),
260
-		__( 'May', 'give' ),
261
-		__( 'June', 'give' ),
262
-		__( 'July', 'give' ),
263
-		__( 'Aug', 'give' ),
264
-		__( 'Sept', 'give' ),
265
-		__( 'Oct', 'give' ),
266
-		__( 'Nov', 'give' ),
267
-		__( 'Dec', 'give' )
268
-	) );
269
-	$chart->addAxis( $x_axis );
270
-
271
-	$shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE );
272
-	$shape_marker->setSize( 6 );
273
-	$shape_marker->setBorder( 2 );
274
-	$shape_marker->setData( $data );
275
-	$chart->addMarker( $shape_marker );
276
-
277
-	$value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE );
278
-	$value_marker->setData( $data );
279
-	$chart->addMarker( $value_marker );
240
+	));
241
+	$data->setLegend(__('Donations', 'give'));
242
+	$data->setColor('ff6c1c');
243
+	$chart->addData($data);
244
+
245
+	$chart->setTitle(__('Donations by Month for all Give Forms', 'give'), '336699', 18);
246
+
247
+	$chart->setScale(0, $max_earnings);
248
+
249
+	$y_axis = new GoogleChartAxis('y');
250
+	$y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings));
251
+	$chart->addAxis($y_axis);
252
+
253
+	$x_axis = new GoogleChartAxis('x');
254
+	$x_axis->setTickMarks(5);
255
+	$x_axis->setLabels(array(
256
+		__('Jan', 'give'),
257
+		__('Feb', 'give'),
258
+		__('Mar', 'give'),
259
+		__('Apr', 'give'),
260
+		__('May', 'give'),
261
+		__('June', 'give'),
262
+		__('July', 'give'),
263
+		__('Aug', 'give'),
264
+		__('Sept', 'give'),
265
+		__('Oct', 'give'),
266
+		__('Nov', 'give'),
267
+		__('Dec', 'give')
268
+	));
269
+	$chart->addAxis($x_axis);
270
+
271
+	$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
272
+	$shape_marker->setSize(6);
273
+	$shape_marker->setBorder(2);
274
+	$shape_marker->setData($data);
275
+	$chart->addMarker($shape_marker);
276
+
277
+	$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
278
+	$value_marker->setData($data);
279
+	$chart->addMarker($value_marker);
280 280
 
281 281
 	return $chart->getUrl();
282 282
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -124,8 +124,10 @@
 block discarded – undo
124 124
 
125 125
 			$pdf->Row( array( $title, $price, $categories, $tags, $sales, $earnings ) );
126 126
 		endforeach;
127
-	else:
127
+	else {
128
+		:
128 129
 		$pdf->SetWidths( array( 280 ) );
130
+	}
129 131
 		$title = utf8_decode( sprintf( __( 'No %s found.', 'give' ), give_get_forms_label_plural() ) );
130 132
 		$pdf->Row( array( $title ) );
131 133
 	endif;
Please login to merge, or discard this patch.