Completed
Pull Request — master (#1619)
by Ravinder
17:48
created
includes/admin/customers/customer-functions.php 1 patch
Spacing   +12 added lines, -12 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
  *
24 24
  * @return array        The altered list of views
25 25
  */
26
-function give_register_default_customer_views( $views ) {
26
+function give_register_default_customer_views($views) {
27 27
 
28 28
 	$default_views = array(
29 29
 		'overview' => 'give_customers_view',
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 		'notes'    => 'give_customer_notes_view'
32 32
 	);
33 33
 
34
-	return array_merge( $views, $default_views );
34
+	return array_merge($views, $default_views);
35 35
 
36 36
 }
37 37
 
38
-add_filter( 'give_customer_views', 'give_register_default_customer_views', 1, 1 );
38
+add_filter('give_customer_views', 'give_register_default_customer_views', 1, 1);
39 39
 
40 40
 /**
41 41
  * Register a tab for the single customer view
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
  *
47 47
  * @return array       The altered list of tabs
48 48
  */
49
-function give_register_default_customer_tabs( $tabs ) {
49
+function give_register_default_customer_tabs($tabs) {
50 50
 
51 51
 	$default_tabs = array(
52
-		'overview' => array( 'dashicon' => 'dashicons-admin-users', 'title' => esc_html__( 'Donor Profile', 'give' ) ),
53
-		'notes'    => array( 'dashicon' => 'dashicons-admin-comments', 'title' => esc_html__( 'Donor Notes', 'give' ) )
52
+		'overview' => array('dashicon' => 'dashicons-admin-users', 'title' => esc_html__('Donor Profile', 'give')),
53
+		'notes'    => array('dashicon' => 'dashicons-admin-comments', 'title' => esc_html__('Donor Notes', 'give'))
54 54
 	);
55 55
 
56
-	return array_merge( $tabs, $default_tabs );
56
+	return array_merge($tabs, $default_tabs);
57 57
 }
58 58
 
59
-add_filter( 'give_customer_tabs', 'give_register_default_customer_tabs', 1, 1 );
59
+add_filter('give_customer_tabs', 'give_register_default_customer_tabs', 1, 1);
60 60
 
61 61
 /**
62 62
  * Register the Delete icon as late as possible so it's at the bottom
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @return array       The altered list of tabs, with 'delete' at the bottom
69 69
  */
70
-function give_register_delete_customer_tab( $tabs ) {
70
+function give_register_delete_customer_tab($tabs) {
71 71
 
72
-	$tabs['delete'] = array( 'dashicon' => 'dashicons-trash', 'title' => esc_html__( 'Delete Donor', 'give' ) );
72
+	$tabs['delete'] = array('dashicon' => 'dashicons-trash', 'title' => esc_html__('Delete Donor', 'give'));
73 73
 
74 74
 	return $tabs;
75 75
 }
76 76
 
77
-add_filter( 'give_customer_tabs', 'give_register_delete_customer_tab', PHP_INT_MAX, 1 );
77
+add_filter('give_customer_tabs', 'give_register_delete_customer_tab', PHP_INT_MAX, 1);
Please login to merge, or discard this patch.
includes/admin/reporting/class-export-earnings.php 1 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,10 +61,10 @@  discard block
 block discarded – undo
61 61
 	public function csv_cols() {
62 62
 
63 63
 		$cols = array(
64
-			'date'      => esc_html__( 'Date', 'give' ),
65
-			'donations' => esc_html__( 'Donations', 'give' ),
64
+			'date'      => esc_html__('Date', 'give'),
65
+			'donations' => esc_html__('Donations', 'give'),
66 66
 			/* translators: %s: currency */
67
-			'earnings'  => sprintf( esc_html__( 'Income (%s)', 'give' ), html_entity_decode( give_currency_filter( '' ) ) )
67
+			'earnings'  => sprintf(esc_html__('Income (%s)', 'give'), html_entity_decode(give_currency_filter('')))
68 68
 		);
69 69
 
70 70
 		return $cols;
@@ -79,28 +79,28 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function get_data() {
81 81
 
82
-		$start_year  = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' );
83
-		$end_year    = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' );
84
-		$start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' );
85
-		$end_month   = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' );
82
+		$start_year  = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y');
83
+		$end_year    = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y');
84
+		$start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n');
85
+		$end_month   = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n');
86 86
 
87 87
 		$data  = array();
88 88
 		$year  = $start_year;
89 89
 		$stats = new Give_Payment_Stats;
90 90
 
91
-		while ( $year <= $end_year ) {
91
+		while ($year <= $end_year) {
92 92
 
93
-			if ( $year == $start_year && $year == $end_year ) {
93
+			if ($year == $start_year && $year == $end_year) {
94 94
 
95 95
 				$m1 = $start_month;
96 96
 				$m2 = $end_month;
97 97
 
98
-			} elseif ( $year == $start_year ) {
98
+			} elseif ($year == $start_year) {
99 99
 
100 100
 				$m1 = $start_month;
101 101
 				$m2 = 12;
102 102
 
103
-			} elseif ( $year == $end_year ) {
103
+			} elseif ($year == $end_year) {
104 104
 
105 105
 				$m1 = 1;
106 106
 				$m2 = $end_month;
@@ -112,28 +112,28 @@  discard block
 block discarded – undo
112 112
 
113 113
 			}
114 114
 
115
-			while ( $m1 <= $m2 ) {
115
+			while ($m1 <= $m2) {
116 116
 
117
-				$date1 = mktime( 0, 0, 0, $m1, 1, $year );
118
-				$date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year );
117
+				$date1 = mktime(0, 0, 0, $m1, 1, $year);
118
+				$date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year);
119 119
 
120 120
 				$data[] = array(
121
-					'date'      => date_i18n( 'F Y', $date1 ),
122
-					'donations' => $stats->get_sales( 0, $date1, $date2 ),
123
-					'earnings'  => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ) ),
121
+					'date'      => date_i18n('F Y', $date1),
122
+					'donations' => $stats->get_sales(0, $date1, $date2),
123
+					'earnings'  => give_format_amount($stats->get_earnings(0, $date1, $date2)),
124 124
 				);
125 125
 
126
-				$m1 ++;
126
+				$m1++;
127 127
 
128 128
 			}
129 129
 
130 130
 
131
-			$year ++;
131
+			$year++;
132 132
 
133 133
 		}
134 134
 
135
-		$data = apply_filters( 'give_export_get_data', $data );
136
-		$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
135
+		$data = apply_filters('give_export_get_data', $data);
136
+		$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
137 137
 
138 138
 		return $data;
139 139
 	}
Please login to merge, or discard this patch.
includes/admin/reporting/tools/class-give-tools-recount-income.php 2 patches
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -53,50 +53,50 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function get_data() {
55 55
 
56
-		if ( $this->step == 1 ) {
57
-			$this->delete_data( 'give_temp_recount_income' );
56
+		if ($this->step == 1) {
57
+			$this->delete_data('give_temp_recount_income');
58 58
 		}
59 59
 
60
-		$total = get_option( 'give_temp_recount_income', false );
60
+		$total = get_option('give_temp_recount_income', false);
61 61
 
62
-		if ( false === $total ) {
62
+		if (false === $total) {
63 63
 			$total = (float) 0;
64
-			$this->store_data( 'give_temp_recount_income', $total );
64
+			$this->store_data('give_temp_recount_income', $total);
65 65
 		}
66 66
 
67
-		$accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) );
67
+		$accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish'));
68 68
 
69
-		$args = apply_filters( 'give_recount_income_args', array(
69
+		$args = apply_filters('give_recount_income_args', array(
70 70
 			'number' => $this->per_step,
71 71
 			'page'   => $this->step,
72 72
 			'status' => $accepted_statuses,
73 73
 			'fields' => 'ids'
74
-		) );
74
+		));
75 75
 
76
-		$payments = give_get_payments( $args );
76
+		$payments = give_get_payments($args);
77 77
 
78
-		if ( ! empty( $payments ) ) {
78
+		if ( ! empty($payments)) {
79 79
 
80
-			foreach ( $payments as $payment ) {
80
+			foreach ($payments as $payment) {
81 81
 
82
-				$total += give_get_payment_amount( $payment );
82
+				$total += give_get_payment_amount($payment);
83 83
 
84 84
 			}
85 85
 
86
-			if ( $total < 0 ) {
86
+			if ($total < 0) {
87 87
 				$totals = 0;
88 88
 			}
89 89
 
90
-			$total = round( $total, give_currency_decimal_filter() );
90
+			$total = round($total, give_currency_decimal_filter());
91 91
 
92
-			$this->store_data( 'give_temp_recount_income', $total );
92
+			$this->store_data('give_temp_recount_income', $total);
93 93
 
94 94
 			return true;
95 95
 
96 96
 		}
97 97
 
98
-		update_option( 'give_income_total', $total );
99
-		set_transient( 'give_income_total', $total, 86400 );
98
+		update_option('give_income_total', $total);
99
+		set_transient('give_income_total', $total, 86400);
100 100
 
101 101
 		return false;
102 102
 
@@ -110,25 +110,25 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function get_percentage_complete() {
112 112
 
113
-		$total = $this->get_stored_data( 'give_recount_income_total' );
113
+		$total = $this->get_stored_data('give_recount_income_total');
114 114
 
115
-		if ( false === $total ) {
116
-			$args = apply_filters( 'give_recount_income_total_args', array() );
115
+		if (false === $total) {
116
+			$args = apply_filters('give_recount_income_total_args', array());
117 117
 
118
-			$counts = give_count_payments( $args );
119
-			$total  = absint( $counts->publish );
120
-			$total  = apply_filters( 'give_recount_store_income_total', $total );
118
+			$counts = give_count_payments($args);
119
+			$total  = absint($counts->publish);
120
+			$total  = apply_filters('give_recount_store_income_total', $total);
121 121
 
122
-			$this->store_data( 'give_recount_income_total', $total );
122
+			$this->store_data('give_recount_income_total', $total);
123 123
 		}
124 124
 
125 125
 		$percentage = 100;
126 126
 
127
-		if ( $total > 0 ) {
128
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
127
+		if ($total > 0) {
128
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
129 129
 		}
130 130
 
131
-		if ( $percentage > 100 ) {
131
+		if ($percentage > 100) {
132 132
 			$percentage = 100;
133 133
 		}
134 134
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @param array $request The Form Data passed into the batch processing
144 144
 	 */
145
-	public function set_properties( $request ) {
145
+	public function set_properties($request) {
146 146
 	}
147 147
 
148 148
 	/**
@@ -153,31 +153,31 @@  discard block
 block discarded – undo
153 153
 	 */
154 154
 	public function process_step() {
155 155
 
156
-		if ( ! $this->can_export() ) {
157
-			wp_die( esc_html__( 'You do not have permission to recount stats.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
156
+		if ( ! $this->can_export()) {
157
+			wp_die(esc_html__('You do not have permission to recount stats.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
158 158
 		}
159 159
 
160 160
 		$had_data = $this->get_data();
161 161
 
162
-		if ( $had_data ) {
162
+		if ($had_data) {
163 163
 			$this->done = false;
164 164
 
165 165
 			return true;
166 166
 		} else {
167
-			$this->delete_data( 'give_recount_income_total' );
168
-			$this->delete_data( 'give_temp_recount_income' );
167
+			$this->delete_data('give_recount_income_total');
168
+			$this->delete_data('give_temp_recount_income');
169 169
 			$this->done    = true;
170
-			$this->message = esc_html__( 'Income stats have been successfully recounted.', 'give' );
170
+			$this->message = esc_html__('Income stats have been successfully recounted.', 'give');
171 171
 
172 172
 			return false;
173 173
 		}
174 174
 	}
175 175
 
176 176
 	public function headers() {
177
-		ignore_user_abort( true );
177
+		ignore_user_abort(true);
178 178
 
179
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
180
-			set_time_limit( 0 );
179
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
180
+			set_time_limit(0);
181 181
 		}
182 182
 	}
183 183
 
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @return mixed       Returns the data from the database
207 207
 	 */
208
-	private function get_stored_data( $key ) {
208
+	private function get_stored_data($key) {
209 209
 		global $wpdb;
210
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
210
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
211 211
 
212
-		return empty( $value ) ? false : maybe_unserialize( $value );
212
+		return empty($value) ? false : maybe_unserialize($value);
213 213
 	}
214 214
 
215 215
 	/**
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @return void
224 224
 	 */
225
-	private function store_data( $key, $value ) {
225
+	private function store_data($key, $value) {
226 226
 		global $wpdb;
227 227
 
228
-		$value = maybe_serialize( $value );
228
+		$value = maybe_serialize($value);
229 229
 
230 230
 		$data = array(
231 231
 			'option_name'  => $key,
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 			'%s',
240 240
 		);
241 241
 
242
-		$wpdb->replace( $wpdb->options, $data, $formats );
242
+		$wpdb->replace($wpdb->options, $data, $formats);
243 243
 	}
244 244
 
245 245
 	/**
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @return void
253 253
 	 */
254
-	private function delete_data( $key ) {
254
+	private function delete_data($key) {
255 255
 		global $wpdb;
256
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
256
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
257 257
 	}
258 258
 
259 259
 }
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
 	 * @access public
50 50
 	 * @since 1.5
51 51
 	 *
52
-	 * @return array $data The data for the CSV file
52
+	 * @return boolean $data The data for the CSV file
53 53
 	 */
54 54
 	public function get_data() {
55 55
 
Please login to merge, or discard this patch.
includes/admin/reporting/tools/class-give-tools-reset-stats.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
 	public function get_data() {
59 59
 		global $wpdb;
60 60
 
61
-		$items = $this->get_stored_data( 'give_temp_reset_ids' );
61
+		$items = $this->get_stored_data('give_temp_reset_ids');
62 62
 
63
-		if ( ! is_array( $items ) ) {
63
+		if ( ! is_array($items)) {
64 64
 			return false;
65 65
 		}
66 66
 
67
-		$offset     = ( $this->step - 1 ) * $this->per_step;
68
-		$step_items = array_slice( $items, $offset, $this->per_step );
67
+		$offset     = ($this->step - 1) * $this->per_step;
68
+		$step_items = array_slice($items, $offset, $this->per_step);
69 69
 
70
-		if ( $step_items ) {
70
+		if ($step_items) {
71 71
 
72 72
 			$step_ids = array(
73 73
 				'customers' => array(),
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 				'other'     => array(),
76 76
 			);
77 77
 
78
-			foreach ( $step_items as $item ) {
78
+			foreach ($step_items as $item) {
79 79
 
80
-				switch ( $item['type'] ) {
80
+				switch ($item['type']) {
81 81
 					case 'customer':
82 82
 						$step_ids['customers'][] = $item['id'];
83 83
 						break;
@@ -85,25 +85,25 @@  discard block
 block discarded – undo
85 85
 						$step_ids['give_forms'][] = $item['id'];
86 86
 						break;
87 87
 					default:
88
-						$item_type                = apply_filters( 'give_reset_item_type', 'other', $item );
89
-						$step_ids[ $item_type ][] = $item['id'];
88
+						$item_type                = apply_filters('give_reset_item_type', 'other', $item);
89
+						$step_ids[$item_type][] = $item['id'];
90 90
 						break;
91 91
 				}
92 92
 			}
93 93
 
94 94
 			$sql = array();
95 95
 
96
-			foreach ( $step_ids as $type => $ids ) {
96
+			foreach ($step_ids as $type => $ids) {
97 97
 
98
-				if ( empty( $ids ) ) {
98
+				if (empty($ids)) {
99 99
 					continue;
100 100
 				}
101 101
 
102
-				$ids = implode( ',', $ids );
102
+				$ids = implode(',', $ids);
103 103
 
104
-				switch ( $type ) {
104
+				switch ($type) {
105 105
 					case 'customers':
106
-						$table_name = $wpdb->prefix . 'give_customers';
106
+						$table_name = $wpdb->prefix.'give_customers';
107 107
 						$sql[]      = "DELETE FROM $table_name WHERE id IN ($ids)";
108 108
 						break;
109 109
 					case 'forms':
@@ -118,16 +118,16 @@  discard block
 block discarded – undo
118 118
 						break;
119 119
 				}
120 120
 
121
-				if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) {
121
+				if ( ! in_array($type, array('customers', 'forms', 'other'))) {
122 122
 					// Allows other types of custom post types to filter on their own post_type
123 123
 					// and add items to the query list, for the IDs found in their post type.
124
-					$sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids );
124
+					$sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids);
125 125
 				}
126 126
 			}
127 127
 
128
-			if ( ! empty( $sql ) ) {
129
-				foreach ( $sql as $query ) {
130
-					$wpdb->query( $query );
128
+			if ( ! empty($sql)) {
129
+				foreach ($sql as $query) {
130
+					$wpdb->query($query);
131 131
 				}
132 132
 			}
133 133
 
@@ -147,16 +147,16 @@  discard block
 block discarded – undo
147 147
 	 */
148 148
 	public function get_percentage_complete() {
149 149
 
150
-		$items = $this->get_stored_data( 'give_temp_reset_ids', false );
151
-		$total = count( $items );
150
+		$items = $this->get_stored_data('give_temp_reset_ids', false);
151
+		$total = count($items);
152 152
 
153 153
 		$percentage = 100;
154 154
 
155
-		if ( $total > 0 ) {
156
-			$percentage = ( ( $this->per_step * $this->step ) / $total ) * 100;
155
+		if ($total > 0) {
156
+			$percentage = (($this->per_step * $this->step) / $total) * 100;
157 157
 		}
158 158
 
159
-		if ( $percentage > 100 ) {
159
+		if ($percentage > 100) {
160 160
 			$percentage = 100;
161 161
 		}
162 162
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @param array $request The Form Data passed into the batch processing
172 172
 	 */
173
-	public function set_properties( $request ) {
173
+	public function set_properties($request) {
174 174
 	}
175 175
 
176 176
 	/**
@@ -181,30 +181,30 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	public function process_step() {
183 183
 
184
-		if ( ! $this->can_export() ) {
185
-			wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
184
+		if ( ! $this->can_export()) {
185
+			wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
186 186
 		}
187 187
 
188 188
 		$had_data = $this->get_data();
189 189
 
190
-		if ( $had_data ) {
190
+		if ($had_data) {
191 191
 			$this->done = false;
192 192
 
193 193
 			return true;
194 194
 		} else {
195
-			update_option( 'give_earnings_total', 0 );
196
-			delete_transient( 'give_earnings_total' );
197
-			delete_transient( 'give_estimated_monthly_stats' . true );
198
-			delete_transient( 'give_estimated_monthly_stats' . false );
199
-			$this->delete_data( 'give_temp_reset_ids' );
195
+			update_option('give_earnings_total', 0);
196
+			delete_transient('give_earnings_total');
197
+			delete_transient('give_estimated_monthly_stats'.true);
198
+			delete_transient('give_estimated_monthly_stats'.false);
199
+			$this->delete_data('give_temp_reset_ids');
200 200
 
201 201
 			// Reset the sequential order numbers
202
-			if ( give_get_option( 'enable_sequential' ) ) {
203
-				delete_option( 'give_last_payment_number' );
202
+			if (give_get_option('enable_sequential')) {
203
+				delete_option('give_last_payment_number');
204 204
 			}
205 205
 
206 206
 			$this->done    = true;
207
-			$this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' );
207
+			$this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give');
208 208
 
209 209
 			return false;
210 210
 		}
@@ -214,10 +214,10 @@  discard block
 block discarded – undo
214 214
 	 * Headers
215 215
 	 */
216 216
 	public function headers() {
217
-		ignore_user_abort( true );
217
+		ignore_user_abort(true);
218 218
 
219
-		if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
220
-			set_time_limit( 0 );
219
+		if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
220
+			set_time_limit(0);
221 221
 		}
222 222
 	}
223 223
 
@@ -241,35 +241,35 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public function pre_fetch() {
243 243
 
244
-		if ( $this->step == 1 ) {
245
-			$this->delete_data( 'give_temp_reset_ids' );
244
+		if ($this->step == 1) {
245
+			$this->delete_data('give_temp_reset_ids');
246 246
 		}
247 247
 
248
-		$items = get_option( 'give_temp_reset_ids', false );
248
+		$items = get_option('give_temp_reset_ids', false);
249 249
 
250
-		if ( false === $items ) {
250
+		if (false === $items) {
251 251
 			$items = array();
252 252
 
253
-			$give_types_for_reset = array( 'give_forms', 'give_log', 'give_payment' );
254
-			$give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset );
253
+			$give_types_for_reset = array('give_forms', 'give_log', 'give_payment');
254
+			$give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset);
255 255
 
256
-			$args = apply_filters( 'give_tools_reset_stats_total_args', array(
256
+			$args = apply_filters('give_tools_reset_stats_total_args', array(
257 257
 				'post_type'      => $give_types_for_reset,
258 258
 				'post_status'    => 'any',
259
-				'posts_per_page' => - 1,
260
-			) );
259
+				'posts_per_page' => -1,
260
+			));
261 261
 
262
-			$posts = get_posts( $args );
263
-			foreach ( $posts as $post ) {
262
+			$posts = get_posts($args);
263
+			foreach ($posts as $post) {
264 264
 				$items[] = array(
265 265
 					'id'   => (int) $post->ID,
266 266
 					'type' => $post->post_type,
267 267
 				);
268 268
 			}
269 269
 
270
-			$customer_args = array( 'number' => - 1 );
271
-			$customers     = Give()->customers->get_customers( $customer_args );
272
-			foreach ( $customers as $customer ) {
270
+			$customer_args = array('number' => -1);
271
+			$customers     = Give()->customers->get_customers($customer_args);
272
+			foreach ($customers as $customer) {
273 273
 				$items[] = array(
274 274
 					'id'   => (int) $customer->id,
275 275
 					'type' => 'customer',
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 
279 279
 			// Allow filtering of items to remove with an unassociative array for each item
280 280
 			// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method
281
-			$items = apply_filters( 'give_reset_items', $items );
281
+			$items = apply_filters('give_reset_items', $items);
282 282
 
283
-			$this->store_data( 'give_temp_reset_ids', $items );
283
+			$this->store_data('give_temp_reset_ids', $items);
284 284
 		}
285 285
 
286 286
 	}
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 	 *
295 295
 	 * @return mixed       Returns the data from the database.
296 296
 	 */
297
-	private function get_stored_data( $key ) {
297
+	private function get_stored_data($key) {
298 298
 		global $wpdb;
299
-		$value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) );
299
+		$value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key));
300 300
 
301
-		return empty( $value ) ? false : maybe_unserialize( $value );
301
+		return empty($value) ? false : maybe_unserialize($value);
302 302
 	}
303 303
 
304 304
 	/**
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
 	 *
312 312
 	 * @return void
313 313
 	 */
314
-	private function store_data( $key, $value ) {
314
+	private function store_data($key, $value) {
315 315
 		global $wpdb;
316 316
 
317
-		$value = maybe_serialize( $value );
317
+		$value = maybe_serialize($value);
318 318
 
319 319
 		$data = array(
320 320
 			'option_name'  => $key,
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 			'%s',
329 329
 		);
330 330
 
331
-		$wpdb->replace( $wpdb->options, $data, $formats );
331
+		$wpdb->replace($wpdb->options, $data, $formats);
332 332
 	}
333 333
 
334 334
 	/**
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 	 *
341 341
 	 * @return void
342 342
 	 */
343
-	private function delete_data( $key ) {
343
+	private function delete_data($key) {
344 344
 		global $wpdb;
345
-		$wpdb->delete( $wpdb->options, array( 'option_name' => $key ) );
345
+		$wpdb->delete($wpdb->options, array('option_name' => $key));
346 346
 	}
347 347
 
348 348
 }
Please login to merge, or discard this patch.
includes/admin/reporting/pdf-reports.php 1 patch
Spacing   +146 added lines, -146 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,82 +25,82 @@  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( esc_html__( 'You do not have permission to generate PDF sales reports.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
30
+	if ( ! current_user_can('view_give_reports')) {
31
+		wp_die(esc_html__('You do not have permission to generate PDF sales reports.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
32 32
 	}
33 33
 
34
-	if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'give_generate_pdf' ) ) {
35
-		wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
34
+	if ( ! wp_verify_nonce($_GET['_wpnonce'], 'give_generate_pdf')) {
35
+		wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('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 41
 	$daterange = utf8_decode(
42 42
 		sprintf(
43 43
 		/* translators: 1: start date 2: end date */
44
-			esc_html__( '%1$s to %2$s', 'give' ),
45
-			date_i18n( give_date_format(), mktime( 0, 0, 0, 1, 1, date( 'Y' ) ) ),
46
-			date_i18n( give_date_format() )
44
+			esc_html__('%1$s to %2$s', 'give'),
45
+			date_i18n(give_date_format(), mktime(0, 0, 0, 1, 1, date('Y'))),
46
+			date_i18n(give_date_format())
47 47
 		)
48 48
 	);
49 49
 
50 50
 	$pdf = new give_pdf();
51
-	$pdf->AddPage( 'L', 'A4' );
51
+	$pdf->AddPage('L', 'A4');
52 52
 
53
-	$pdf->SetTitle( utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ) );
54
-	$pdf->SetAuthor( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) );
55
-	$pdf->SetCreator( utf8_decode( __( 'Give - Democratizing Generosity', 'give' ) ) );
53
+	$pdf->SetTitle(utf8_decode(__('Donation report for the current year for all forms', 'give')));
54
+	$pdf->SetAuthor(utf8_decode(__('Give - Democratizing Generosity', 'give')));
55
+	$pdf->SetCreator(utf8_decode(__('Give - Democratizing Generosity', 'give')));
56 56
 
57
-	$pdf->Image( apply_filters( 'give_pdf_export_logo', GIVE_PLUGIN_URL . 'assets/images/give-logo-small.png' ), 247, 8 );
57
+	$pdf->Image(apply_filters('give_pdf_export_logo', GIVE_PLUGIN_URL.'assets/images/give-logo-small.png'), 247, 8);
58 58
 
59
-	$pdf->SetMargins( 8, 8, 8 );
60
-	$pdf->SetX( 8 );
59
+	$pdf->SetMargins(8, 8, 8);
60
+	$pdf->SetX(8);
61 61
 
62
-	$pdf->SetFont( 'Helvetica', '', 16 );
63
-	$pdf->SetTextColor( 50, 50, 50 );
64
-	$pdf->Cell( 0, 3, utf8_decode( __( 'Donation report for the current year for all forms', 'give' ) ), 0, 2, 'L', false );
62
+	$pdf->SetFont('Helvetica', '', 16);
63
+	$pdf->SetTextColor(50, 50, 50);
64
+	$pdf->Cell(0, 3, utf8_decode(__('Donation report for the current year for all forms', 'give')), 0, 2, 'L', false);
65 65
 
66
-	$pdf->SetFont( 'Helvetica', '', 13 );
66
+	$pdf->SetFont('Helvetica', '', 13);
67 67
 	$pdf->Ln();
68
-	$pdf->SetTextColor( 150, 150, 150 );
69
-	$pdf->Cell( 0, 6, utf8_decode( __( 'Date Range: ', 'give' ) ) . $daterange, 0, 2, 'L', false );
68
+	$pdf->SetTextColor(150, 150, 150);
69
+	$pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'give')).$daterange, 0, 2, 'L', false);
70 70
 	$pdf->Ln();
71
-	$pdf->SetTextColor( 50, 50, 50 );
72
-	$pdf->SetFont( 'Helvetica', '', 14 );
73
-	$pdf->Cell( 0, 10, utf8_decode( __( 'Table View', 'give' ) ), 0, 2, 'L', false );
74
-	$pdf->SetFont( 'Helvetica', '', 12 );
71
+	$pdf->SetTextColor(50, 50, 50);
72
+	$pdf->SetFont('Helvetica', '', 14);
73
+	$pdf->Cell(0, 10, utf8_decode(__('Table View', 'give')), 0, 2, 'L', false);
74
+	$pdf->SetFont('Helvetica', '', 12);
75 75
 
76
-	$pdf->SetFillColor( 238, 238, 238 );
77
-	$pdf->Cell( 70, 6, utf8_decode( __( 'Form Name', 'give' ) ), 1, 0, 'L', true );
78
-	$pdf->Cell( 30, 6, utf8_decode( __( 'Price', 'give' ) ), 1, 0, 'L', true );
79
-	$pdf->Cell( 50, 6, utf8_decode( __( 'Categories', 'give' ) ), 1, 0, 'L', true );
80
-	$pdf->Cell( 50, 6, utf8_decode( __( 'Tags', 'give' ) ), 1, 0, 'L', true );
81
-	$pdf->Cell( 45, 6, utf8_decode( __( 'Number of Donations', 'give' ) ), 1, 0, 'L', true );
82
-	$pdf->Cell( 35, 6, utf8_decode( __( 'Income to Date', 'give' ) ), 1, 1, 'L', true );
76
+	$pdf->SetFillColor(238, 238, 238);
77
+	$pdf->Cell(70, 6, utf8_decode(__('Form Name', 'give')), 1, 0, 'L', true);
78
+	$pdf->Cell(30, 6, utf8_decode(__('Price', 'give')), 1, 0, 'L', true);
79
+	$pdf->Cell(50, 6, utf8_decode(__('Categories', 'give')), 1, 0, 'L', true);
80
+	$pdf->Cell(50, 6, utf8_decode(__('Tags', 'give')), 1, 0, 'L', true);
81
+	$pdf->Cell(45, 6, utf8_decode(__('Number of Donations', 'give')), 1, 0, 'L', true);
82
+	$pdf->Cell(35, 6, utf8_decode(__('Income to Date', 'give')), 1, 1, 'L', true);
83 83
 
84
-	$year       = date( 'Y' );
85
-	$give_forms = get_posts( array( 'post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => - 1 ) );
84
+	$year       = date('Y');
85
+	$give_forms = get_posts(array('post_type' => 'give_forms', 'year' => $year, 'posts_per_page' => -1));
86 86
 
87
-	if ( $give_forms ) {
88
-		$pdf->SetWidths( array( 70, 30, 50, 50, 45, 35 ) );
87
+	if ($give_forms) {
88
+		$pdf->SetWidths(array(70, 30, 50, 50, 45, 35));
89 89
 
90
-		foreach ( $give_forms as $form ):
91
-			$pdf->SetFillColor( 255, 255, 255 );
90
+		foreach ($give_forms as $form):
91
+			$pdf->SetFillColor(255, 255, 255);
92 92
 
93 93
 			$title = $form->post_title;
94 94
 
95
-			if ( give_has_variable_prices( $form->ID ) ) {
95
+			if (give_has_variable_prices($form->ID)) {
96 96
 
97
-				$prices = give_get_variable_prices( $form->ID );
97
+				$prices = give_get_variable_prices($form->ID);
98 98
 
99 99
 				$first = $prices[0]['_give_amount'];
100
-				$last  = array_pop( $prices );
100
+				$last  = array_pop($prices);
101 101
 				$last  = $last['_give_amount'];
102 102
 
103
-				if ( $first < $last ) {
103
+				if ($first < $last) {
104 104
 					$min = $first;
105 105
 					$max = $last;
106 106
 				} else {
@@ -108,51 +108,51 @@  discard block
 block discarded – undo
108 108
 					$max = $first;
109 109
 				}
110 110
 
111
-				$price = html_entity_decode( give_currency_filter( give_format_amount( $min ) ) . ' - ' . give_currency_filter( give_format_amount( $max ) ) );
111
+				$price = html_entity_decode(give_currency_filter(give_format_amount($min)).' - '.give_currency_filter(give_format_amount($max)));
112 112
 			} else {
113
-				$price = html_entity_decode( give_currency_filter( give_get_form_price( $form->ID ) ) );
113
+				$price = html_entity_decode(give_currency_filter(give_get_form_price($form->ID)));
114 114
 			}
115 115
 
116
-			$categories = get_the_term_list( $form->ID, 'give_forms_category', '', ', ', '' );
117
-			$categories = ! is_wp_error( $categories ) ? strip_tags( $categories ) : '';
116
+			$categories = get_the_term_list($form->ID, 'give_forms_category', '', ', ', '');
117
+			$categories = ! is_wp_error($categories) ? strip_tags($categories) : '';
118 118
 
119
-			$tags = get_the_term_list( $form->ID, 'give_forms_tag', '', ', ', '' );
120
-			$tags = ! is_wp_error( $tags ) ? strip_tags( $tags ) : '';
119
+			$tags = get_the_term_list($form->ID, 'give_forms_tag', '', ', ', '');
120
+			$tags = ! is_wp_error($tags) ? strip_tags($tags) : '';
121 121
 
122
-			$sales    = give_get_form_sales_stats( $form->ID );
123
-			$link     = get_permalink( $form->ID );
124
-			$earnings = html_entity_decode( give_currency_filter( give_get_form_earnings_stats( $form->ID ) ) );
122
+			$sales    = give_get_form_sales_stats($form->ID);
123
+			$link     = get_permalink($form->ID);
124
+			$earnings = html_entity_decode(give_currency_filter(give_get_form_earnings_stats($form->ID)));
125 125
 
126
-			if ( function_exists( 'iconv' ) ) {
126
+			if (function_exists('iconv')) {
127 127
 				// Ensure characters like euro; are properly converted.
128
-				$price    = iconv( 'UTF-8', 'windows-1252', utf8_encode( $price ) );
129
-				$earnings = iconv( 'UTF-8', 'windows-1252', utf8_encode( $earnings ) );
128
+				$price    = iconv('UTF-8', 'windows-1252', utf8_encode($price));
129
+				$earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings));
130 130
 			}
131 131
 
132
-			$pdf->Row( array( $title, $price, $categories, $tags, $sales, $earnings ) );
132
+			$pdf->Row(array($title, $price, $categories, $tags, $sales, $earnings));
133 133
 		endforeach;
134 134
 	} else {
135
-		$pdf->SetWidths( array( 280 ) );
136
-		$title = utf8_decode( esc_html__( 'No forms found.', 'give' ) );
137
-		$pdf->Row( array( $title ) );
135
+		$pdf->SetWidths(array(280));
136
+		$title = utf8_decode(esc_html__('No forms found.', 'give'));
137
+		$pdf->Row(array($title));
138 138
 	}
139 139
 
140 140
 	$pdf->Ln();
141
-	$pdf->SetTextColor( 50, 50, 50 );
142
-	$pdf->SetFont( 'Helvetica', '', 14 );
143
-	$pdf->Cell( 0, 10, utf8_decode( __( 'Graph View', 'give' ) ), 0, 2, 'L', false );
144
-	$pdf->SetFont( 'Helvetica', '', 12 );
145
-
146
-	$image = html_entity_decode( urldecode( give_draw_chart_image() ) );
147
-	$image = str_replace( ' ', '%20', $image );
148
-
149
-	$pdf->SetX( 25 );
150
-	$pdf->Image( $image . '&file=.png' );
151
-	$pdf->Ln( 7 );
152
-	$pdf->Output( apply_filters( 'give_sales_earnings_pdf_export_filename', 'give-report-' . date_i18n( 'Y-m-d' ) ) . '.pdf', 'D' );
141
+	$pdf->SetTextColor(50, 50, 50);
142
+	$pdf->SetFont('Helvetica', '', 14);
143
+	$pdf->Cell(0, 10, utf8_decode(__('Graph View', 'give')), 0, 2, 'L', false);
144
+	$pdf->SetFont('Helvetica', '', 12);
145
+
146
+	$image = html_entity_decode(urldecode(give_draw_chart_image()));
147
+	$image = str_replace(' ', '%20', $image);
148
+
149
+	$pdf->SetX(25);
150
+	$pdf->Image($image.'&file=.png');
151
+	$pdf->Ln(7);
152
+	$pdf->Output(apply_filters('give_sales_earnings_pdf_export_filename', 'give-report-'.date_i18n('Y-m-d')).'.pdf', 'D');
153 153
 }
154 154
 
155
-add_action( 'give_generate_pdf', 'give_generate_pdf' );
155
+add_action('give_generate_pdf', 'give_generate_pdf');
156 156
 
157 157
 /**
158 158
  * Draws Chart for PDF Report.
@@ -169,38 +169,38 @@  discard block
 block discarded – undo
169 169
  * @return string $chart->getUrl() URL for the Google Chart
170 170
  */
171 171
 function give_draw_chart_image() {
172
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/GoogleChart.php';
173
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php';
174
-	require_once GIVE_PLUGIN_DIR . '/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php';
172
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/GoogleChart.php';
173
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartShapeMarker.php';
174
+	require_once GIVE_PLUGIN_DIR.'/includes/libraries/googlechartlib/markers/GoogleChartTextMarker.php';
175 175
 
176
-	$chart = new GoogleChart( 'lc', 900, 330 );
176
+	$chart = new GoogleChart('lc', 900, 330);
177 177
 
178 178
 	$i        = 1;
179 179
 	$earnings = "";
180 180
 	$sales    = "";
181 181
 
182
-	while ( $i <= 12 ) :
183
-		$earnings .= give_get_earnings_by_date( null, $i, date( 'Y' ) ) . ",";
184
-		$sales .= give_get_sales_by_date( null, $i, date( 'Y' ) ) . ",";
185
-		$i ++;
182
+	while ($i <= 12) :
183
+		$earnings .= give_get_earnings_by_date(null, $i, date('Y')).",";
184
+		$sales .= give_get_sales_by_date(null, $i, date('Y')).",";
185
+		$i++;
186 186
 	endwhile;
187 187
 
188
-	$earnings_array = explode( ",", $earnings );
189
-	$sales_array    = explode( ",", $sales );
188
+	$earnings_array = explode(",", $earnings);
189
+	$sales_array    = explode(",", $sales);
190 190
 
191 191
 	$i = 0;
192
-	while ( $i <= 11 ) {
193
-		if ( empty( $sales_array[ $i ] ) ) {
194
-			$sales_array[ $i ] = 0;
192
+	while ($i <= 11) {
193
+		if (empty($sales_array[$i])) {
194
+			$sales_array[$i] = 0;
195 195
 		}
196
-		$i ++;
196
+		$i++;
197 197
 	}
198 198
 
199 199
 	$min_earnings   = 0;
200
-	$max_earnings   = max( $earnings_array );
201
-	$earnings_scale = round( $max_earnings, - 1 );
200
+	$max_earnings   = max($earnings_array);
201
+	$earnings_scale = round($max_earnings, - 1);
202 202
 
203
-	$data = new GoogleChartData( array(
203
+	$data = new GoogleChartData(array(
204 204
 		$earnings_array[0],
205 205
 		$earnings_array[1],
206 206
 		$earnings_array[2],
@@ -213,25 +213,25 @@  discard block
 block discarded – undo
213 213
 		$earnings_array[9],
214 214
 		$earnings_array[10],
215 215
 		$earnings_array[11]
216
-	) );
216
+	));
217 217
 
218
-	$data->setLegend( esc_html__( 'Income', 'give' ) );
219
-	$data->setColor( '1b58a3' );
220
-	$chart->addData( $data );
218
+	$data->setLegend(esc_html__('Income', 'give'));
219
+	$data->setColor('1b58a3');
220
+	$chart->addData($data);
221 221
 
222
-	$shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE );
223
-	$shape_marker->setColor( '000000' );
224
-	$shape_marker->setSize( 7 );
225
-	$shape_marker->setBorder( 2 );
226
-	$shape_marker->setData( $data );
227
-	$chart->addMarker( $shape_marker );
222
+	$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
223
+	$shape_marker->setColor('000000');
224
+	$shape_marker->setSize(7);
225
+	$shape_marker->setBorder(2);
226
+	$shape_marker->setData($data);
227
+	$chart->addMarker($shape_marker);
228 228
 
229
-	$value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE );
230
-	$value_marker->setColor( '000000' );
231
-	$value_marker->setData( $data );
232
-	$chart->addMarker( $value_marker );
229
+	$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
230
+	$value_marker->setColor('000000');
231
+	$value_marker->setData($data);
232
+	$chart->addMarker($value_marker);
233 233
 
234
-	$data = new GoogleChartData( array(
234
+	$data = new GoogleChartData(array(
235 235
 		$sales_array[0],
236 236
 		$sales_array[1],
237 237
 		$sales_array[2],
@@ -244,46 +244,46 @@  discard block
 block discarded – undo
244 244
 		$sales_array[9],
245 245
 		$sales_array[10],
246 246
 		$sales_array[11]
247
-	) );
248
-	$data->setLegend( esc_html__( 'Donations', 'give' ) );
249
-	$data->setColor( 'ff6c1c' );
250
-	$chart->addData( $data );
251
-
252
-	$chart->setTitle( esc_html__( 'Donations by Month for all Give Forms', 'give' ), '336699', 18 );
253
-
254
-	$chart->setScale( 0, $max_earnings );
255
-
256
-	$y_axis = new GoogleChartAxis( 'y' );
257
-	$y_axis->setDrawTickMarks( true )->setLabels( array( 0, $max_earnings ) );
258
-	$chart->addAxis( $y_axis );
259
-
260
-	$x_axis = new GoogleChartAxis( 'x' );
261
-	$x_axis->setTickMarks( 5 );
262
-	$x_axis->setLabels( array(
263
-		esc_html__( 'Jan', 'give' ),
264
-		esc_html__( 'Feb', 'give' ),
265
-		esc_html__( 'Mar', 'give' ),
266
-		esc_html__( 'Apr', 'give' ),
267
-		esc_html__( 'May', 'give' ),
268
-		esc_html__( 'June', 'give' ),
269
-		esc_html__( 'July', 'give' ),
270
-		esc_html__( 'Aug', 'give' ),
271
-		esc_html__( 'Sept', 'give' ),
272
-		esc_html__( 'Oct', 'give' ),
273
-		esc_html__( 'Nov', 'give' ),
274
-		esc_html__( 'Dec', 'give' )
275
-	) );
276
-	$chart->addAxis( $x_axis );
277
-
278
-	$shape_marker = new GoogleChartShapeMarker( GoogleChartShapeMarker::CIRCLE );
279
-	$shape_marker->setSize( 6 );
280
-	$shape_marker->setBorder( 2 );
281
-	$shape_marker->setData( $data );
282
-	$chart->addMarker( $shape_marker );
283
-
284
-	$value_marker = new GoogleChartTextMarker( GoogleChartTextMarker::VALUE );
285
-	$value_marker->setData( $data );
286
-	$chart->addMarker( $value_marker );
247
+	));
248
+	$data->setLegend(esc_html__('Donations', 'give'));
249
+	$data->setColor('ff6c1c');
250
+	$chart->addData($data);
251
+
252
+	$chart->setTitle(esc_html__('Donations by Month for all Give Forms', 'give'), '336699', 18);
253
+
254
+	$chart->setScale(0, $max_earnings);
255
+
256
+	$y_axis = new GoogleChartAxis('y');
257
+	$y_axis->setDrawTickMarks(true)->setLabels(array(0, $max_earnings));
258
+	$chart->addAxis($y_axis);
259
+
260
+	$x_axis = new GoogleChartAxis('x');
261
+	$x_axis->setTickMarks(5);
262
+	$x_axis->setLabels(array(
263
+		esc_html__('Jan', 'give'),
264
+		esc_html__('Feb', 'give'),
265
+		esc_html__('Mar', 'give'),
266
+		esc_html__('Apr', 'give'),
267
+		esc_html__('May', 'give'),
268
+		esc_html__('June', 'give'),
269
+		esc_html__('July', 'give'),
270
+		esc_html__('Aug', 'give'),
271
+		esc_html__('Sept', 'give'),
272
+		esc_html__('Oct', 'give'),
273
+		esc_html__('Nov', 'give'),
274
+		esc_html__('Dec', 'give')
275
+	));
276
+	$chart->addAxis($x_axis);
277
+
278
+	$shape_marker = new GoogleChartShapeMarker(GoogleChartShapeMarker::CIRCLE);
279
+	$shape_marker->setSize(6);
280
+	$shape_marker->setBorder(2);
281
+	$shape_marker->setData($data);
282
+	$chart->addMarker($shape_marker);
283
+
284
+	$value_marker = new GoogleChartTextMarker(GoogleChartTextMarker::VALUE);
285
+	$value_marker->setData($data);
286
+	$chart->addMarker($value_marker);
287 287
 
288 288
 	return $chart->getUrl();
289 289
 }
Please login to merge, or discard this patch.
includes/admin/reporting/class-give-graph.php 1 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
 						}
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		 *
315 315
 		 * @param Give_Graph $this Graph object.
316 316
 		 */
317
-		do_action( 'give_before_graph', $this );
317
+		do_action('give_before_graph', $this);
318 318
 
319 319
 		// Build the graph.
320 320
 		echo $this->build_graph();
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 		 *
327 327
 		 * @param Give_Graph $this Graph object.
328 328
 		 */
329
-		do_action( 'give_after_graph', $this );
329
+		do_action('give_after_graph', $this);
330 330
 	}
331 331
 
332 332
 }
Please login to merge, or discard this patch.
includes/admin/reporting/class-export.php 1 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'   => esc_html__( 'ID', 'give' ),
73
-			'date' => esc_html__( 'Date', 'give' )
72
+			'id'   => esc_html__('ID', 'give'),
73
+			'date' => esc_html__('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( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
176
+		if ( ! $this->can_export()) {
177
+			wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
178 178
 		}
179 179
 
180 180
 		// Set headers
Please login to merge, or discard this patch.
includes/admin/reporting/export/class-batch-export-forms.php 1 patch
Spacing   +53 added lines, -53 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
 
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
 	public function csv_cols() {
42 42
 
43 43
 		$cols = array(
44
-			'ID'                      => esc_html__( 'ID', 'give' ),
45
-			'post_name'               => esc_html__( 'Slug', 'give' ),
46
-			'post_title'              => esc_html__( 'Name', 'give' ),
47
-			'post_date'               => esc_html__( 'Date Created', 'give' ),
48
-			'post_author'             => esc_html__( 'Author', 'give' ),
49
-			'post_content'            => esc_html__( 'Description', 'give' ),
50
-			'post_excerpt'            => esc_html__( 'Excerpt', 'give' ),
51
-			'post_status'             => esc_html__( 'Status', 'give' ),
52
-			'categories'              => esc_html__( 'Categories', 'give' ),
53
-			'tags'                    => esc_html__( 'Tags', 'give' ),
54
-			'give_price'              => esc_html__( 'Price', 'give' ),
55
-			'_thumbnail_id'           => esc_html__( 'Featured Image', 'give' ),
56
-			'_give_form_sales'        => esc_html__( 'Donations', 'give' ),
57
-			'_give_download_earnings' => esc_html__( 'Income', 'give' ),
44
+			'ID'                      => esc_html__('ID', 'give'),
45
+			'post_name'               => esc_html__('Slug', 'give'),
46
+			'post_title'              => esc_html__('Name', 'give'),
47
+			'post_date'               => esc_html__('Date Created', 'give'),
48
+			'post_author'             => esc_html__('Author', 'give'),
49
+			'post_content'            => esc_html__('Description', 'give'),
50
+			'post_excerpt'            => esc_html__('Excerpt', 'give'),
51
+			'post_status'             => esc_html__('Status', 'give'),
52
+			'categories'              => esc_html__('Categories', 'give'),
53
+			'tags'                    => esc_html__('Tags', 'give'),
54
+			'give_price'              => esc_html__('Price', 'give'),
55
+			'_thumbnail_id'           => esc_html__('Featured Image', 'give'),
56
+			'_give_form_sales'        => esc_html__('Donations', 'give'),
57
+			'_give_download_earnings' => esc_html__('Income', 'give'),
58 58
 		);
59 59
 
60 60
 		return $cols;
@@ -86,43 +86,43 @@  discard block
 block discarded – undo
86 86
 			'paged'          => $this->step
87 87
 		);
88 88
 
89
-		$downloads = new WP_Query( $args );
89
+		$downloads = new WP_Query($args);
90 90
 
91
-		if ( $downloads->posts ) {
92
-			foreach ( $downloads->posts as $download ) {
91
+		if ($downloads->posts) {
92
+			foreach ($downloads->posts as $download) {
93 93
 
94 94
 				$row = array();
95 95
 
96
-				foreach ( $this->csv_cols() as $key => $value ) {
96
+				foreach ($this->csv_cols() as $key => $value) {
97 97
 
98 98
 					// Setup default value
99
-					$row[ $key ] = '';
99
+					$row[$key] = '';
100 100
 
101
-					if ( in_array( $key, $meta ) ) {
101
+					if (in_array($key, $meta)) {
102 102
 
103
-						switch ( $key ) {
103
+						switch ($key) {
104 104
 
105 105
 							case '_thumbnail_id' :
106 106
 
107
-								$image_id    = get_post_thumbnail_id( $download->ID );
108
-								$row[ $key ] = wp_get_attachment_url( $image_id );
107
+								$image_id    = get_post_thumbnail_id($download->ID);
108
+								$row[$key] = wp_get_attachment_url($image_id);
109 109
 
110 110
 								break;
111 111
 
112 112
 							case 'give_price' :
113 113
 
114
-								if ( give_has_variable_prices( $download->ID ) ) {
114
+								if (give_has_variable_prices($download->ID)) {
115 115
 
116 116
 									$prices = array();
117
-									foreach ( give_get_variable_prices( $download->ID ) as $price ) {
118
-										$prices[] = $price['name'] . ': ' . $price['amount'];
117
+									foreach (give_get_variable_prices($download->ID) as $price) {
118
+										$prices[] = $price['name'].': '.$price['amount'];
119 119
 									}
120 120
 
121
-									$row[ $key ] = implode( ' | ', $prices );
121
+									$row[$key] = implode(' | ', $prices);
122 122
 
123 123
 								} else {
124 124
 
125
-									$row[ $key ] = give_get_download_price( $download->ID );
125
+									$row[$key] = give_get_download_price($download->ID);
126 126
 
127 127
 								}
128 128
 
@@ -132,54 +132,54 @@  discard block
 block discarded – undo
132 132
 
133 133
 
134 134
 								$files = array();
135
-								foreach ( give_get_download_files( $download->ID ) as $file ) {
135
+								foreach (give_get_download_files($download->ID) as $file) {
136 136
 									$files[] = $file['file'];
137 137
 								}
138 138
 
139
-								$row[ $key ] = implode( ' | ', $files );
139
+								$row[$key] = implode(' | ', $files);
140 140
 
141 141
 								break;
142 142
 
143 143
 							default :
144 144
 
145
-								$row[ $key ] = get_post_meta( $download->ID, $key, true );
145
+								$row[$key] = get_post_meta($download->ID, $key, true);
146 146
 
147 147
 								break;
148 148
 
149 149
 						}
150 150
 
151
-					} elseif ( isset( $download->$key ) ) {
151
+					} elseif (isset($download->$key)) {
152 152
 
153
-						switch ( $key ) {
153
+						switch ($key) {
154 154
 
155 155
 							case 'post_author' :
156 156
 
157
-								$row[ $key ] = get_the_author_meta( 'user_login', $download->post_author );
157
+								$row[$key] = get_the_author_meta('user_login', $download->post_author);
158 158
 
159 159
 								break;
160 160
 
161 161
 							default :
162 162
 
163
-								$row[ $key ] = $download->$key;
163
+								$row[$key] = $download->$key;
164 164
 
165 165
 								break;
166 166
 						}
167 167
 
168
-					} elseif ( 'tags' == $key ) {
168
+					} elseif ('tags' == $key) {
169 169
 
170
-						$terms = get_the_terms( $download->ID, 'download_tag' );
171
-						if ( $terms ) {
172
-							$terms       = wp_list_pluck( $terms, 'name' );
173
-							$row[ $key ] = implode( ' | ', $terms );
170
+						$terms = get_the_terms($download->ID, 'download_tag');
171
+						if ($terms) {
172
+							$terms       = wp_list_pluck($terms, 'name');
173
+							$row[$key] = implode(' | ', $terms);
174 174
 						}
175 175
 
176 176
 
177
-					} elseif ( 'categories' == $key ) {
177
+					} elseif ('categories' == $key) {
178 178
 
179
-						$terms = get_the_terms( $download->ID, 'download_category' );
180
-						if ( $terms ) {
181
-							$terms       = wp_list_pluck( $terms, 'name' );
182
-							$row[ $key ] = implode( ' | ', $terms );
179
+						$terms = get_the_terms($download->ID, 'download_category');
180
+						if ($terms) {
181
+							$terms       = wp_list_pluck($terms, 'name');
182
+							$row[$key] = implode(' | ', $terms);
183 183
 						}
184 184
 
185 185
 					}
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 
191 191
 			}
192 192
 
193
-			$data = apply_filters( 'give_export_get_data', $data );
194
-			$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
193
+			$data = apply_filters('give_export_get_data', $data);
194
+			$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
195 195
 
196 196
 			return $data;
197 197
 		}
@@ -210,20 +210,20 @@  discard block
 block discarded – undo
210 210
 
211 211
 		$args = array(
212 212
 			'post_type'      => 'give_forms',
213
-			'posts_per_page' => - 1,
213
+			'posts_per_page' => -1,
214 214
 			'post_status'    => 'any',
215 215
 			'fields'         => 'ids',
216 216
 		);
217 217
 
218
-		$downloads  = new WP_Query( $args );
218
+		$downloads  = new WP_Query($args);
219 219
 		$total      = (int) $downloads->post_count;
220 220
 		$percentage = 100;
221 221
 
222
-		if ( $total > 0 ) {
223
-			$percentage = ( ( 30 * $this->step ) / $total ) * 100;
222
+		if ($total > 0) {
223
+			$percentage = ((30 * $this->step) / $total) * 100;
224 224
 		}
225 225
 
226
-		if ( $percentage > 100 ) {
226
+		if ($percentage > 100) {
227 227
 			$percentage = 100;
228 228
 		}
229 229
 
Please login to merge, or discard this patch.
includes/admin/reporting/export/export-functions.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
18
-require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-export.php';
19
-require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/export-actions.php';
18
+require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/class-export.php';
19
+require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/export-actions.php';
20 20
 
21 21
 /**
22 22
  * Process batch exports via ajax
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function give_do_ajax_export() {
28 28
 
29
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/export/class-batch-export.php';
29
+	require_once GIVE_PLUGIN_DIR.'includes/admin/reporting/export/class-batch-export.php';
30 30
 
31
-	parse_str( $_POST['form'], $form );
31
+	parse_str($_POST['form'], $form);
32 32
 
33 33
 	$_REQUEST = $form = (array) $form;
34 34
 
35
-	if ( ! wp_verify_nonce( $_REQUEST['give_ajax_export'], 'give_ajax_export' ) ) {
36
-		die( '-2' );
35
+	if ( ! wp_verify_nonce($_REQUEST['give_ajax_export'], 'give_ajax_export')) {
36
+		die('-2');
37 37
 	}
38 38
 
39 39
 	/**
@@ -43,69 +43,69 @@  discard block
 block discarded – undo
43 43
 	 *
44 44
 	 * @param string $class Export class.
45 45
 	 */
46
-	do_action( 'give_batch_export_class_include', $form['give-export-class'] );
46
+	do_action('give_batch_export_class_include', $form['give-export-class']);
47 47
 
48
-	$step   = absint( $_POST['step'] );
49
-	$class  = sanitize_text_field( $form['give-export-class'] );
48
+	$step   = absint($_POST['step']);
49
+	$class  = sanitize_text_field($form['give-export-class']);
50 50
 
51
-	$export = new $class( $step );
51
+	$export = new $class($step);
52 52
 
53
-	if ( ! $export->can_export() ) {
54
-		die( '-1' );
53
+	if ( ! $export->can_export()) {
54
+		die('-1');
55 55
 	}
56 56
 
57
-	if ( ! $export->is_writable ) {
57
+	if ( ! $export->is_writable) {
58 58
 		$json_args = array(
59 59
 			'error'   => true,
60
-			'message' => esc_html__( 'Export location or file not writable.', 'give' )
60
+			'message' => esc_html__('Export location or file not writable.', 'give')
61 61
 		);
62 62
 		echo json_encode($json_args);
63 63
 		exit;
64 64
 	}
65 65
 
66
-	$export->set_properties( $_REQUEST );
66
+	$export->set_properties($_REQUEST);
67 67
 
68 68
 	$export->pre_fetch();
69 69
 
70
-	$ret = $export->process_step( $step );
70
+	$ret = $export->process_step($step);
71 71
 
72 72
 	$percentage = $export->get_percentage_complete();
73 73
 
74
-	if ( $ret ) {
74
+	if ($ret) {
75 75
 
76 76
 		$step += 1;
77
-		echo json_encode( array( 'step' => $step, 'percentage' => $percentage ) );
77
+		echo json_encode(array('step' => $step, 'percentage' => $percentage));
78 78
 		exit;
79 79
 
80
-	} elseif ( true === $export->is_empty ) {
80
+	} elseif (true === $export->is_empty) {
81 81
 
82
-		echo json_encode( array(
82
+		echo json_encode(array(
83 83
 			'error'   => true,
84
-			'message' => esc_html__( 'No data found for export parameters.', 'give' )
85
-		) );
84
+			'message' => esc_html__('No data found for export parameters.', 'give')
85
+		));
86 86
 		exit;
87 87
 
88
-	} elseif ( true === $export->done && true === $export->is_void ) {
88
+	} elseif (true === $export->done && true === $export->is_void) {
89 89
 
90
-		$message = ! empty( $export->message ) ? $export->message : esc_html__( 'Batch Processing Complete', 'give' );
91
-		echo json_encode( array( 'success' => true, 'message' => $message ) );
90
+		$message = ! empty($export->message) ? $export->message : esc_html__('Batch Processing Complete', 'give');
91
+		echo json_encode(array('success' => true, 'message' => $message));
92 92
 		exit;
93 93
 
94 94
 	} else {
95 95
 		
96
-		$args = array_merge( $_REQUEST, array(
96
+		$args = array_merge($_REQUEST, array(
97 97
 			'step'        => $step,
98 98
 			'class'       => $class,
99
-			'nonce'       => wp_create_nonce( 'give-batch-export' ),
99
+			'nonce'       => wp_create_nonce('give-batch-export'),
100 100
 			'give_action' => 'form_batch_export',
101
-		) );
101
+		));
102 102
 
103
-		$download_url = add_query_arg( $args, admin_url() );
103
+		$download_url = add_query_arg($args, admin_url());
104 104
 
105
-		echo json_encode( array( 'step' => 'done', 'url' => $download_url ) );
105
+		echo json_encode(array('step' => 'done', 'url' => $download_url));
106 106
 		exit;
107 107
 
108 108
 	}
109 109
 }
110 110
 
111
-add_action( 'wp_ajax_give_do_ajax_export', 'give_do_ajax_export' );
111
+add_action('wp_ajax_give_do_ajax_export', 'give_do_ajax_export');
Please login to merge, or discard this patch.