Completed
Pull Request — master (#1055)
by Rami
19:01
created
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/class-gateway-error-logs-list-table.php 1 patch
Spacing   +50 added lines, -50 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
 /**
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	public function __construct() {
46 46
 		// Set parent defaults.
47
-		parent::__construct( array(
48
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records.
49
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records.
47
+		parent::__construct(array(
48
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records.
49
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records.
50 50
 			'ajax'     => false                        // Does this table support ajax?.
51
-		) );
51
+		));
52 52
 	}
53 53
 
54 54
 	/**
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return string Column Name.
64 64
 	 */
65
-	public function column_default( $item, $column_name ) {
65
+	public function column_default($item, $column_name) {
66 66
 
67
-		switch ( $column_name ) {
67
+		switch ($column_name) {
68 68
 			case 'ID' :
69 69
 				return $item['ID_label'];
70 70
 			case 'payment_id' :
71
-				return empty( $item->payment_id ) ? esc_html__( 'n/a', 'give' ) : $item->payment_id;
71
+				return empty($item->payment_id) ? esc_html__('n/a', 'give') : $item->payment_id;
72 72
 			case 'gateway' :
73
-				return empty( $item->gateway ) ? esc_html__( 'n/a', 'give' ) : $item->gateway;
73
+				return empty($item->gateway) ? esc_html__('n/a', 'give') : $item->gateway;
74 74
 			case 'error' :
75
-				return get_the_title( $item['ID'] ) ? get_the_title( $item['ID'] ) : esc_html__( 'Payment Error', 'give' );
75
+				return get_the_title($item['ID']) ? get_the_title($item['ID']) : esc_html__('Payment Error', 'give');
76 76
 			default:
77
-				return $item[ $column_name ];
77
+				return $item[$column_name];
78 78
 		}
79 79
 	}
80 80
 
@@ -88,27 +88,27 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return void
90 90
 	 */
91
-	public function column_message( $item ) { ?>
92
-		<a href="#TB_inline?width=640&amp;inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e( 'View Log Message', 'give' ); ?>"><span class="dashicons dashicons-visibility"></span></a>
91
+	public function column_message($item) { ?>
92
+		<a href="#TB_inline?width=640&amp;inlineId=log-message-<?php echo $item['ID']; ?>" class="thickbox give-error-log-details-link button button-small" data-tooltip="<?php esc_attr_e('View Log Message', 'give'); ?>"><span class="dashicons dashicons-visibility"></span></a>
93 93
 		<div id="log-message-<?php echo $item['ID']; ?>" style="display:none;">
94 94
 			<?php
95 95
 
96
-			$log_message = get_post_field( 'post_content', $item['ID'] );
96
+			$log_message = get_post_field('post_content', $item['ID']);
97 97
 
98
-			$serialized = strpos( $log_message, '{"' );
98
+			$serialized = strpos($log_message, '{"');
99 99
 
100 100
 			// Check to see if the log message contains serialized information
101
-			if ( $serialized !== false ) {
102
-				$length = strlen( $log_message ) - $serialized;
103
-				$intro  = substr( $log_message, 0, - $length );
104
-				$data   = substr( $log_message, $serialized, strlen( $log_message ) - 1 );
101
+			if ($serialized !== false) {
102
+				$length = strlen($log_message) - $serialized;
103
+				$intro  = substr($log_message, 0, - $length);
104
+				$data   = substr($log_message, $serialized, strlen($log_message) - 1);
105 105
 
106
-				echo wpautop( $intro );
107
-				echo wpautop( '<strong>' . esc_html__( 'Log data:', 'give' ) . '</strong>' );
108
-				echo '<div style="word-wrap: break-word;">' . wpautop( $data ) . '</div>';
106
+				echo wpautop($intro);
107
+				echo wpautop('<strong>'.esc_html__('Log data:', 'give').'</strong>');
108
+				echo '<div style="word-wrap: break-word;">'.wpautop($data).'</div>';
109 109
 			} else {
110 110
 				// No serialized data found
111
-				echo wpautop( $log_message );
111
+				echo wpautop($log_message);
112 112
 			}
113 113
 			?>
114 114
 		</div>
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 	 */
125 125
 	public function get_columns() {
126 126
 		$columns = array(
127
-			'ID'         => esc_html__( 'Log ID', 'give' ),
128
-			'error'      => esc_html__( 'Error', 'give' ),
129
-			'gateway'    => esc_html__( 'Gateway', 'give' ),
130
-			'payment_id' => esc_html__( 'Donation ID', 'give' ),
131
-			'date'       => esc_html__( 'Date', 'give' ),
132
-			'message'    => esc_html__( 'Details', 'give' )
127
+			'ID'         => esc_html__('Log ID', 'give'),
128
+			'error'      => esc_html__('Error', 'give'),
129
+			'gateway'    => esc_html__('Gateway', 'give'),
130
+			'payment_id' => esc_html__('Donation ID', 'give'),
131
+			'date'       => esc_html__('Date', 'give'),
132
+			'message'    => esc_html__('Details', 'give')
133 133
 		);
134 134
 
135 135
 		return $columns;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * @return int Current page number
144 144
 	 */
145 145
 	public function get_paged() {
146
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
146
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
147 147
 	}
148 148
 
149 149
 	/**
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @since  1.0
154 154
 	 * @return void
155 155
 	 */
156
-	public function bulk_actions( $which = '' ) {
156
+	public function bulk_actions($which = '') {
157 157
 		give_log_views();
158 158
 	}
159 159
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 		// Prevent the queries from getting cached.
173 173
 		// Without this there are occasional memory issues for some installs.
174
-		wp_suspend_cache_addition( true );
174
+		wp_suspend_cache_addition(true);
175 175
 
176 176
 		$logs_data = array();
177 177
 		$paged     = $this->get_paged();
@@ -180,17 +180,17 @@  discard block
 block discarded – undo
180 180
 			'paged'    => $paged
181 181
 		);
182 182
 
183
-		$logs = $give_logs->get_connected_logs( $log_query );
183
+		$logs = $give_logs->get_connected_logs($log_query);
184 184
 
185
-		if ( $logs ) {
186
-			foreach ( $logs as $log ) {
185
+		if ($logs) {
186
+			foreach ($logs as $log) {
187 187
 
188 188
 				$logs_data[] = array(
189 189
 					'ID'         => $log->ID,
190
-					'ID_label'   => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>',
190
+					'ID_label'   => '<span class=\'give-item-label give-item-label-gray\'>'.$log->ID.'</span>',
191 191
 					'payment_id' => $log->post_parent,
192 192
 					'error'      => 'error',
193
-					'gateway'    => give_get_payment_gateway( $log->post_parent ),
193
+					'gateway'    => give_get_payment_gateway($log->post_parent),
194 194
 					'date'       => $log->post_date
195 195
 				);
196 196
 			}
@@ -212,19 +212,19 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @param string $which
214 214
 	 */
215
-	protected function display_tablenav( $which ) {
216
-		if ( 'top' === $which ) {
217
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
215
+	protected function display_tablenav($which) {
216
+		if ('top' === $which) {
217
+			wp_nonce_field('bulk-'.$this->_args['plural']);
218 218
 		}
219 219
 		?>
220
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
220
+		<div class="tablenav <?php echo esc_attr($which); ?>">
221 221
 
222 222
 			<div class="alignleft actions bulkactions">
223
-				<?php $this->bulk_actions( $which ); ?>
223
+				<?php $this->bulk_actions($which); ?>
224 224
 			</div>
225 225
 			<?php
226
-			$this->extra_tablenav( $which );
227
-			$this->pagination( $which );
226
+			$this->extra_tablenav($which);
227
+			$this->pagination($which);
228 228
 			?>
229 229
 
230 230
 			<br class="clear"/>
@@ -251,14 +251,14 @@  discard block
 block discarded – undo
251 251
 		$columns               = $this->get_columns();
252 252
 		$hidden                = array(); // No hidden columns
253 253
 		$sortable              = $this->get_sortable_columns();
254
-		$this->_column_headers = array( $columns, $hidden, $sortable );
254
+		$this->_column_headers = array($columns, $hidden, $sortable);
255 255
 		$this->items           = $this->get_logs();
256
-		$total_items           = $give_logs->get_log_count( 0, 'gateway_error' );
256
+		$total_items           = $give_logs->get_log_count(0, 'gateway_error');
257 257
 
258
-		$this->set_pagination_args( array(
258
+		$this->set_pagination_args(array(
259 259
 				'total_items' => $total_items,
260 260
 				'per_page'    => $this->per_page,
261
-				'total_pages' => ceil( $total_items / $this->per_page )
261
+				'total_pages' => ceil($total_items / $this->per_page)
262 262
 			)
263 263
 		);
264 264
 	}
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/admin-actions.php 2 patches
Spacing   +13 added lines, -13 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
 
@@ -24,51 +24,51 @@  discard block
 block discarded – undo
24 24
 function give_hide_subscription_notices() {
25 25
 
26 26
     // Hide subscription notices permanently.
27
-    if ( ! empty( $_GET['_give_hide_license_notices_permanently'] ) ) {
27
+    if ( ! empty($_GET['_give_hide_license_notices_permanently'])) {
28 28
         global $current_user;
29 29
 
30 30
         // check previously disabled notice ids.
31
-        $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) )
31
+        $already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true))
32 32
             ? $already_dismiss_notices
33 33
             : array();
34 34
 
35 35
         // Get notice id.
36
-        $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_permanently'] );
36
+        $notice_id = sanitize_text_field($_GET['_give_hide_license_notices_permanently']);
37 37
 
38
-        if( ! in_array( $notice_id, $already_dismiss_notices ) ) {
38
+        if ( ! in_array($notice_id, $already_dismiss_notices)) {
39 39
             $already_dismiss_notices[] = $notice_id;
40 40
         }
41 41
 
42 42
         // Store subscription ids.
43
-        update_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices );
43
+        update_user_meta($current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices);
44 44
 
45 45
         // Redirect user.
46
-        wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'] ) );
46
+        wp_safe_redirect(remove_query_arg('_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI']));
47 47
         exit();
48 48
     }
49 49
 
50 50
     // Hide subscription notices shortly.
51
-    if ( ! empty( $_GET['_give_hide_license_notices_shortly'] ) ) {
51
+    if ( ! empty($_GET['_give_hide_license_notices_shortly'])) {
52 52
         global $current_user;
53 53
 
54 54
         // Get notice id.
55
-        $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_shortly'] );
55
+        $notice_id = sanitize_text_field($_GET['_give_hide_license_notices_shortly']);
56 56
 
57 57
         // Transient key name.
58 58
         $transient_key = "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}";
59 59
 
60
-        if( get_transient( $transient_key ) ) {
60
+        if (get_transient($transient_key)) {
61 61
             return;
62 62
         }
63 63
 
64 64
 
65 65
         // Hide notice for 24 hours.
66
-        set_transient( $transient_key, true, 24 * HOUR_IN_SECONDS );
66
+        set_transient($transient_key, true, 24 * HOUR_IN_SECONDS);
67 67
 
68 68
         // Redirect user.
69
-        wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'] ) );
69
+        wp_safe_redirect(remove_query_arg('_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI']));
70 70
         exit();
71 71
     }
72 72
 }
73 73
 
74
-add_action( 'admin_init', 'give_hide_subscription_notices' );
75 74
\ No newline at end of file
75
+add_action('admin_init', 'give_hide_subscription_notices');
76 76
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -23,52 +23,52 @@
 block discarded – undo
23 23
  */
24 24
 function give_hide_subscription_notices() {
25 25
 
26
-    // Hide subscription notices permanently.
27
-    if ( ! empty( $_GET['_give_hide_license_notices_permanently'] ) ) {
28
-        $current_user = wp_get_current_user();
26
+	// Hide subscription notices permanently.
27
+	if ( ! empty( $_GET['_give_hide_license_notices_permanently'] ) ) {
28
+		$current_user = wp_get_current_user();
29 29
 
30
-        // check previously disabled notice ids.
31
-        $already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) )
32
-            ? $already_dismiss_notices
33
-            : array();
30
+		// check previously disabled notice ids.
31
+		$already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) )
32
+			? $already_dismiss_notices
33
+			: array();
34 34
 
35
-        // Get notice id.
36
-        $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_permanently'] );
35
+		// Get notice id.
36
+		$notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_permanently'] );
37 37
 
38
-        if( ! in_array( $notice_id, $already_dismiss_notices ) ) {
39
-            $already_dismiss_notices[] = $notice_id;
40
-        }
38
+		if( ! in_array( $notice_id, $already_dismiss_notices ) ) {
39
+			$already_dismiss_notices[] = $notice_id;
40
+		}
41 41
 
42
-        // Store subscription ids.
43
-        update_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices );
42
+		// Store subscription ids.
43
+		update_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', $already_dismiss_notices );
44 44
 
45
-        // Redirect user.
46
-        wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'] ) );
47
-        exit();
48
-    }
45
+		// Redirect user.
46
+		wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_permanently', $_SERVER['REQUEST_URI'] ) );
47
+		exit();
48
+	}
49 49
 
50
-    // Hide subscription notices shortly.
51
-    if ( ! empty( $_GET['_give_hide_license_notices_shortly'] ) ) {
52
-        $current_user = wp_get_current_user();
50
+	// Hide subscription notices shortly.
51
+	if ( ! empty( $_GET['_give_hide_license_notices_shortly'] ) ) {
52
+		$current_user = wp_get_current_user();
53 53
 
54
-        // Get notice id.
55
-        $notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_shortly'] );
54
+		// Get notice id.
55
+		$notice_id = sanitize_text_field( $_GET['_give_hide_license_notices_shortly'] );
56 56
 
57
-        // Transient key name.
58
-        $transient_key = "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}";
57
+		// Transient key name.
58
+		$transient_key = "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}";
59 59
 
60
-        if( get_transient( $transient_key ) ) {
61
-            return;
62
-        }
60
+		if( get_transient( $transient_key ) ) {
61
+			return;
62
+		}
63 63
 
64 64
 
65
-        // Hide notice for 24 hours.
66
-        set_transient( $transient_key, true, 24 * HOUR_IN_SECONDS );
65
+		// Hide notice for 24 hours.
66
+		set_transient( $transient_key, true, 24 * HOUR_IN_SECONDS );
67 67
 
68
-        // Redirect user.
69
-        wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'] ) );
70
-        exit();
71
-    }
68
+		// Redirect user.
69
+		wp_safe_redirect( remove_query_arg( '_give_hide_license_notices_shortly', $_SERVER['REQUEST_URI'] ) );
70
+		exit();
71
+	}
72 72
 }
73 73
 
74 74
 add_action( 'admin_init', 'give_hide_subscription_notices' );
75 75
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/upgrades/upgrade-functions.php 2 patches
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 
15 15
 // Exit if accessed directly
16
-if ( ! defined( 'ABSPATH' ) ) {
16
+if ( ! defined('ABSPATH')) {
17 17
 	exit;
18 18
 }
19 19
 
@@ -26,30 +26,30 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function give_do_automatic_upgrades() {
28 28
 	$did_upgrade  = false;
29
-	$give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) );
29
+	$give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version'));
30 30
 
31
-	if ( ! $give_version ) {
31
+	if ( ! $give_version) {
32 32
 		// 1.0 is the first version to use this option so we must add it.
33 33
 		$give_version = '1.0';
34 34
 	}
35 35
 
36
-	switch ( true ) {
36
+	switch (true) {
37 37
 
38
-		case version_compare( $give_version, '1.6', '<' ) :
38
+		case version_compare($give_version, '1.6', '<') :
39 39
 			give_v16_upgrades();
40 40
 			$did_upgrade = true;
41 41
 
42
-		case version_compare( $give_version, '1.7', '<' ) :
42
+		case version_compare($give_version, '1.7', '<') :
43 43
 			give_v17_upgrades();
44 44
 			$did_upgrade = true;
45 45
 	}
46 46
 
47
-	if ( $did_upgrade ) {
48
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
47
+	if ($did_upgrade) {
48
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
49 49
 	}
50 50
 }
51 51
 
52
-add_action( 'admin_init', 'give_do_automatic_upgrades' );
52
+add_action('admin_init', 'give_do_automatic_upgrades');
53 53
 
54 54
 /**
55 55
  * Display Upgrade Notices
@@ -59,18 +59,18 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function give_show_upgrade_notices() {
61 61
 
62
-	if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) {
62
+	if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') {
63 63
 		return;
64 64
 	} // Don't show notices on the upgrades page
65 65
 
66
-	$give_version = get_option( 'give_version' );
66
+	$give_version = get_option('give_version');
67 67
 
68
-	if ( ! $give_version ) {
68
+	if ( ! $give_version) {
69 69
 		// 1.0 is the first version to use this option so we must add it
70 70
 		$give_version = '1.0';
71 71
 	}
72 72
 
73
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
73
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
74 74
 
75 75
 	/*
76 76
 	 *  NOTICE:
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 
83 83
 	//v1.3.2 Upgrades
84
-	if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) {
84
+	if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) {
85 85
 		printf(
86 86
 		/* translators: %s: upgrade URL */
87
-			'<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>',
88
-			esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) )
87
+			'<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>',
88
+			esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id'))
89 89
 		);
90 90
 	}
91 91
 
92 92
 	//v1.3.4 Upgrades //ensure the user has gone through 1.3.4
93
-	if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) {
93
+	if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) {
94 94
 		printf(
95 95
 		/* translators: %s: upgrade URL */
96
-			'<div class="updated"><p>' . __( 'Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>',
97
-			esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) )
96
+			'<div class="updated"><p>'.__('Give needs to upgrade the donations database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>',
97
+			esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status'))
98 98
 		);
99 99
 	}
100 100
 
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 
105 105
 }
106 106
 
107
-add_action( 'admin_notices', 'give_show_upgrade_notices' );
107
+add_action('admin_notices', 'give_show_upgrade_notices');
108 108
 
109 109
 /**
110 110
  * Triggers all upgrade functions
@@ -116,26 +116,26 @@  discard block
 block discarded – undo
116 116
  */
117 117
 function give_trigger_upgrades() {
118 118
 
119
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
120
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
119
+	if ( ! current_user_can('manage_give_settings')) {
120
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
121 121
 	}
122 122
 
123
-	$give_version = get_option( 'give_version' );
123
+	$give_version = get_option('give_version');
124 124
 
125
-	if ( ! $give_version ) {
125
+	if ( ! $give_version) {
126 126
 		// 1.0 is the first version to use this option so we must add it
127 127
 		$give_version = '1.0';
128
-		add_option( 'give_version', $give_version );
128
+		add_option('give_version', $give_version);
129 129
 	}
130 130
 
131
-	update_option( 'give_version', GIVE_VERSION );
131
+	update_option('give_version', GIVE_VERSION);
132 132
 
133
-	if ( DOING_AJAX ) {
134
-		die( 'complete' );
133
+	if (DOING_AJAX) {
134
+		die('complete');
135 135
 	} // Let AJAX know that the upgrade is complete
136 136
 }
137 137
 
138
-add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' );
138
+add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades');
139 139
 
140 140
 /**
141 141
  * Check if the upgrade routine has been run for a specific action
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
  *
147 147
  * @return bool                   If the action has been added to the completed actions array
148 148
  */
149
-function give_has_upgrade_completed( $upgrade_action = '' ) {
149
+function give_has_upgrade_completed($upgrade_action = '') {
150 150
 
151
-	if ( empty( $upgrade_action ) ) {
151
+	if (empty($upgrade_action)) {
152 152
 		return false;
153 153
 	}
154 154
 
155 155
 	$completed_upgrades = give_get_completed_upgrades();
156 156
 
157
-	return in_array( $upgrade_action, $completed_upgrades );
157
+	return in_array($upgrade_action, $completed_upgrades);
158 158
 
159 159
 }
160 160
 
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
  *
168 168
  * @return bool                   If the function was successfully added
169 169
  */
170
-function give_set_upgrade_complete( $upgrade_action = '' ) {
170
+function give_set_upgrade_complete($upgrade_action = '') {
171 171
 
172
-	if ( empty( $upgrade_action ) ) {
172
+	if (empty($upgrade_action)) {
173 173
 		return false;
174 174
 	}
175 175
 
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
 	$completed_upgrades[] = $upgrade_action;
178 178
 
179 179
 	// Remove any blanks, and only show uniques
180
-	$completed_upgrades = array_unique( array_values( $completed_upgrades ) );
180
+	$completed_upgrades = array_unique(array_values($completed_upgrades));
181 181
 
182
-	return update_option( 'give_completed_upgrades', $completed_upgrades );
182
+	return update_option('give_completed_upgrades', $completed_upgrades);
183 183
 }
184 184
 
185 185
 /**
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
  */
191 191
 function give_get_completed_upgrades() {
192 192
 
193
-	$completed_upgrades = get_option( 'give_completed_upgrades' );
193
+	$completed_upgrades = get_option('give_completed_upgrades');
194 194
 
195
-	if ( false === $completed_upgrades ) {
195
+	if (false === $completed_upgrades) {
196 196
 		$completed_upgrades = array();
197 197
 	}
198 198
 
@@ -210,30 +210,30 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function give_v132_upgrade_give_payment_customer_id() {
212 212
 	global $wpdb;
213
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
214
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
213
+	if ( ! current_user_can('manage_give_settings')) {
214
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
215 215
 	}
216 216
 
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
 	//UPDATE DB METAKEYS
224 224
 	$sql   = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'";
225
-	$query = $wpdb->query( $sql );
225
+	$query = $wpdb->query($sql);
226 226
 
227
-	update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
228
-	give_set_upgrade_complete( 'upgrade_give_payment_customer_id' );
229
-	delete_option( 'give_doing_upgrade' );
230
-	wp_redirect( admin_url() );
227
+	update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
228
+	give_set_upgrade_complete('upgrade_give_payment_customer_id');
229
+	delete_option('give_doing_upgrade');
230
+	wp_redirect(admin_url());
231 231
 	exit;
232 232
 
233 233
 
234 234
 }
235 235
 
236
-add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' );
236
+add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id');
237 237
 
238 238
 /**
239 239
  * Upgrades the Offline Status
@@ -247,14 +247,14 @@  discard block
 block discarded – undo
247 247
 
248 248
 	global $wpdb;
249 249
 
250
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
251
-		wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
250
+	if ( ! current_user_can('manage_give_settings')) {
251
+		wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
252 252
 	}
253 253
 
254
-	ignore_user_abort( true );
254
+	ignore_user_abort(true);
255 255
 
256
-	if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) {
257
-		@set_time_limit( 0 );
256
+	if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) {
257
+		@set_time_limit(0);
258 258
 	}
259 259
 
260 260
 	// Get abandoned offline payments
@@ -264,35 +264,35 @@  discard block
 block discarded – undo
264 264
 	$where .= "AND ( p.post_status = 'abandoned' )";
265 265
 	$where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )";
266 266
 
267
-	$sql            = $select . $join . $where;
268
-	$found_payments = $wpdb->get_col( $sql );
267
+	$sql            = $select.$join.$where;
268
+	$found_payments = $wpdb->get_col($sql);
269 269
 
270 270
 
271
-	foreach ( $found_payments as $payment ) {
271
+	foreach ($found_payments as $payment) {
272 272
 
273 273
 		//Only change ones marked abandoned since our release last week
274 274
 		//because the admin may have marked some abandoned themselves
275
-		$modified_time = get_post_modified_time( 'U', false, $payment );
275
+		$modified_time = get_post_modified_time('U', false, $payment);
276 276
 
277 277
 		//1450124863 =  12/10/2015 20:42:25
278
-		if ( $modified_time >= 1450124863 ) {
278
+		if ($modified_time >= 1450124863) {
279 279
 
280
-			give_update_payment_status( $payment, 'pending' );
280
+			give_update_payment_status($payment, 'pending');
281 281
 
282 282
 		}
283 283
 
284 284
 	}
285 285
 
286
-	update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
287
-	give_set_upgrade_complete( 'upgrade_give_offline_status' );
288
-	delete_option( 'give_doing_upgrade' );
289
-	wp_redirect( admin_url() );
286
+	update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
287
+	give_set_upgrade_complete('upgrade_give_offline_status');
288
+	delete_option('give_doing_upgrade');
289
+	wp_redirect(admin_url());
290 290
 	exit;
291 291
 
292 292
 
293 293
 }
294 294
 
295
-add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' );
295
+add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status');
296 296
 
297 297
 /**
298 298
  * Cleanup User Roles
@@ -303,17 +303,17 @@  discard block
 block discarded – undo
303 303
  */
304 304
 function give_v152_cleanup_users() {
305 305
 
306
-	$give_version = get_option( 'give_version' );
306
+	$give_version = get_option('give_version');
307 307
 
308
-	if ( ! $give_version ) {
308
+	if ( ! $give_version) {
309 309
 		// 1.0 is the first version to use this option so we must add it
310 310
 		$give_version = '1.0';
311 311
 	}
312 312
 
313
-	$give_version = preg_replace( '/[^0-9.].*/', '', $give_version );
313
+	$give_version = preg_replace('/[^0-9.].*/', '', $give_version);
314 314
 
315 315
 	//v1.5.2 Upgrades
316
-	if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) {
316
+	if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) {
317 317
 
318 318
 		//Delete all caps with "ss"
319 319
 		//Also delete all unused "campaign" roles
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 		);
361 361
 
362 362
 		global $wp_roles;
363
-		foreach ( $delete_caps as $cap ) {
364
-			foreach ( array_keys( $wp_roles->roles ) as $role ) {
365
-				$wp_roles->remove_cap( $role, $cap );
363
+		foreach ($delete_caps as $cap) {
364
+			foreach (array_keys($wp_roles->roles) as $role) {
365
+				$wp_roles->remove_cap($role, $cap);
366 366
 			}
367 367
 		}
368 368
 
@@ -372,15 +372,15 @@  discard block
 block discarded – undo
372 372
 		$roles->add_caps();
373 373
 
374 374
 		//The Update Ran
375
-		update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) );
376
-		give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' );
377
-		delete_option( 'give_doing_upgrade' );
375
+		update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION));
376
+		give_set_upgrade_complete('upgrade_give_user_caps_cleanup');
377
+		delete_option('give_doing_upgrade');
378 378
 
379 379
 	}
380 380
 
381 381
 }
382 382
 
383
-add_action( 'admin_init', 'give_v152_cleanup_users' );
383
+add_action('admin_init', 'give_v152_cleanup_users');
384 384
 
385 385
 /**
386 386
  * 1.6 Upgrade routine to create the customer meta table.
@@ -410,60 +410,60 @@  discard block
 block discarded – undo
410 410
  *
411 411
  * @since 1.7
412 412
  */
413
-function give_upgrade_addon_license_data(){
413
+function give_upgrade_addon_license_data() {
414 414
     global $give_options;
415 415
 
416 416
     $api_url = 'https://givewp.com/give-sl-api/';
417 417
 
418 418
     // Get addons license key.
419 419
     $addons = array();
420
-    foreach ( $give_options as $key => $value ) {
421
-        if( false !== strpos( $key, '_license_key' ) ) {
420
+    foreach ($give_options as $key => $value) {
421
+        if (false !== strpos($key, '_license_key')) {
422 422
             $addons[$key] = $value;
423 423
         }
424 424
     }
425 425
 
426 426
     // Bailout: We do not have any addon license data to upgrade.
427
-    if( empty( $addons ) ) {
427
+    if (empty($addons)) {
428 428
         return false;
429 429
     }
430 430
     
431
-    foreach ( $addons as $key => $addon_license ) {
431
+    foreach ($addons as $key => $addon_license) {
432 432
 
433 433
         // Get addon shortname.
434
-        $shortname = str_replace( '_license_key', '', $key );
434
+        $shortname = str_replace('_license_key', '', $key);
435 435
 
436 436
         // Addon license option name.
437
-        $addon_license_option_name = $shortname . '_license_active';
437
+        $addon_license_option_name = $shortname.'_license_active';
438 438
 
439 439
         // bailout if license is empty.
440
-        if( empty( $addon_license ) ) {
441
-            delete_option( $addon_license_option_name );
440
+        if (empty($addon_license)) {
441
+            delete_option($addon_license_option_name);
442 442
             continue;
443 443
         }
444 444
 
445 445
         // Get addon name.
446 446
         $addon_name = array();
447
-        $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) );
448
-        foreach ( $addon_name_parts as $name_part ) {
447
+        $addon_name_parts = explode('_', str_replace('give_', '', $shortname));
448
+        foreach ($addon_name_parts as $name_part) {
449 449
 
450 450
             // Fix addon name
451
-            switch ( $name_part ) {
451
+            switch ($name_part) {
452 452
                 case 'authorizenet' :
453 453
                     $name_part = 'authorize.net';
454 454
                     break;
455 455
             }
456 456
 
457
-            $addon_name[] = ucfirst( $name_part );
457
+            $addon_name[] = ucfirst($name_part);
458 458
         }
459 459
 
460
-        $addon_name = implode( ' ', $addon_name );
460
+        $addon_name = implode(' ', $addon_name);
461 461
 
462 462
         // Data to send to the API
463 463
         $api_params = array(
464 464
             'edd_action' => 'activate_license', //never change from "edd_" to "give_"!
465 465
             'license'    => $addon_license,
466
-            'item_name'  => urlencode( $addon_name ),
466
+            'item_name'  => urlencode($addon_name),
467 467
             'url'        => home_url()
468 468
         );
469 469
 
@@ -478,16 +478,16 @@  discard block
 block discarded – undo
478 478
         );
479 479
 
480 480
         // Make sure there are no errors
481
-        if ( is_wp_error( $response ) ) {
482
-            delete_option( $addon_license_option_name );
481
+        if (is_wp_error($response)) {
482
+            delete_option($addon_license_option_name);
483 483
             continue;
484 484
         }
485 485
 
486 486
         // Tell WordPress to look for updates
487
-        set_site_transient( 'update_plugins', null );
487
+        set_site_transient('update_plugins', null);
488 488
 
489 489
         // Decode license data
490
-        $license_data = json_decode( wp_remote_retrieve_body( $response ) );
491
-        update_option( $addon_license_option_name, $license_data );
490
+        $license_data = json_decode(wp_remote_retrieve_body($response));
491
+        update_option($addon_license_option_name, $license_data);
492 492
     }
493 493
 }
494 494
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -411,83 +411,83 @@
 block discarded – undo
411 411
  * @since 1.7
412 412
  */
413 413
 function give_upgrade_addon_license_data(){
414
-    $give_options = give_get_settings();
415
-
416
-    $api_url = 'https://givewp.com/give-sl-api/';
417
-
418
-    // Get addons license key.
419
-    $addons = array();
420
-    foreach ( $give_options as $key => $value ) {
421
-        if( false !== strpos( $key, '_license_key' ) ) {
422
-            $addons[$key] = $value;
423
-        }
424
-    }
425
-
426
-    // Bailout: We do not have any addon license data to upgrade.
427
-    if( empty( $addons ) ) {
428
-        return false;
429
-    }
414
+	$give_options = give_get_settings();
415
+
416
+	$api_url = 'https://givewp.com/give-sl-api/';
417
+
418
+	// Get addons license key.
419
+	$addons = array();
420
+	foreach ( $give_options as $key => $value ) {
421
+		if( false !== strpos( $key, '_license_key' ) ) {
422
+			$addons[$key] = $value;
423
+		}
424
+	}
425
+
426
+	// Bailout: We do not have any addon license data to upgrade.
427
+	if( empty( $addons ) ) {
428
+		return false;
429
+	}
430 430
     
431
-    foreach ( $addons as $key => $addon_license ) {
432
-
433
-        // Get addon shortname.
434
-        $shortname = str_replace( '_license_key', '', $key );
435
-
436
-        // Addon license option name.
437
-        $addon_license_option_name = $shortname . '_license_active';
438
-
439
-        // bailout if license is empty.
440
-        if( empty( $addon_license ) ) {
441
-            delete_option( $addon_license_option_name );
442
-            continue;
443
-        }
444
-
445
-        // Get addon name.
446
-        $addon_name = array();
447
-        $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) );
448
-        foreach ( $addon_name_parts as $name_part ) {
449
-
450
-            // Fix addon name
451
-            switch ( $name_part ) {
452
-                case 'authorizenet' :
453
-                    $name_part = 'authorize.net';
454
-                    break;
455
-            }
456
-
457
-            $addon_name[] = ucfirst( $name_part );
458
-        }
459
-
460
-        $addon_name = implode( ' ', $addon_name );
461
-
462
-        // Data to send to the API
463
-        $api_params = array(
464
-            'edd_action' => 'activate_license', //never change from "edd_" to "give_"!
465
-            'license'    => $addon_license,
466
-            'item_name'  => urlencode( $addon_name ),
467
-            'url'        => home_url()
468
-        );
469
-
470
-        // Call the API
471
-        $response = wp_remote_post(
472
-            $api_url,
473
-            array(
474
-                'timeout'   => 15,
475
-                'sslverify' => false,
476
-                'body'      => $api_params
477
-            )
478
-        );
479
-
480
-        // Make sure there are no errors
481
-        if ( is_wp_error( $response ) ) {
482
-            delete_option( $addon_license_option_name );
483
-            continue;
484
-        }
485
-
486
-        // Tell WordPress to look for updates
487
-        set_site_transient( 'update_plugins', null );
488
-
489
-        // Decode license data
490
-        $license_data = json_decode( wp_remote_retrieve_body( $response ) );
491
-        update_option( $addon_license_option_name, $license_data );
492
-    }
431
+	foreach ( $addons as $key => $addon_license ) {
432
+
433
+		// Get addon shortname.
434
+		$shortname = str_replace( '_license_key', '', $key );
435
+
436
+		// Addon license option name.
437
+		$addon_license_option_name = $shortname . '_license_active';
438
+
439
+		// bailout if license is empty.
440
+		if( empty( $addon_license ) ) {
441
+			delete_option( $addon_license_option_name );
442
+			continue;
443
+		}
444
+
445
+		// Get addon name.
446
+		$addon_name = array();
447
+		$addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) );
448
+		foreach ( $addon_name_parts as $name_part ) {
449
+
450
+			// Fix addon name
451
+			switch ( $name_part ) {
452
+				case 'authorizenet' :
453
+					$name_part = 'authorize.net';
454
+					break;
455
+			}
456
+
457
+			$addon_name[] = ucfirst( $name_part );
458
+		}
459
+
460
+		$addon_name = implode( ' ', $addon_name );
461
+
462
+		// Data to send to the API
463
+		$api_params = array(
464
+			'edd_action' => 'activate_license', //never change from "edd_" to "give_"!
465
+			'license'    => $addon_license,
466
+			'item_name'  => urlencode( $addon_name ),
467
+			'url'        => home_url()
468
+		);
469
+
470
+		// Call the API
471
+		$response = wp_remote_post(
472
+			$api_url,
473
+			array(
474
+				'timeout'   => 15,
475
+				'sslverify' => false,
476
+				'body'      => $api_params
477
+			)
478
+		);
479
+
480
+		// Make sure there are no errors
481
+		if ( is_wp_error( $response ) ) {
482
+			delete_option( $addon_license_option_name );
483
+			continue;
484
+		}
485
+
486
+		// Tell WordPress to look for updates
487
+		set_site_transient( 'update_plugins', null );
488
+
489
+		// Decode license data
490
+		$license_data = json_decode( wp_remote_retrieve_body( $response ) );
491
+		update_option( $addon_license_option_name, $license_data );
492
+	}
493 493
 }
494 494
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/customers/customer-actions.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
  * and redirect back to the donor interface for feedback
544 544
  *
545 545
  * @since  1.7
546
- * @return void|bool
546
+ * @return false|null
547 547
  */
548 548
 function give_remove_donor_email() {
549 549
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
  * and redirect back to the donor interface for feedback
584 584
  *
585 585
  * @since  1.7
586
- * @return void|bool
586
+ * @return false|null
587 587
  */
588 588
 function give_set_donor_primary_email() {
589 589
 	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
Please login to merge, or discard this patch.
Spacing   +189 added lines, -189 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,15 +23,15 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return array $output Response messages
25 25
  */
26
-function give_edit_customer( $args ) {
26
+function give_edit_customer($args) {
27 27
 	
28
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
28
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
29 29
 
30
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
31
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
30
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
31
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
32 32
 	}
33 33
 
34
-	if ( empty( $args ) ) {
34
+	if (empty($args)) {
35 35
 		return;
36 36
 	}
37 37
 
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 	$customer_id   = (int) $args['customerinfo']['id'];
40 40
 	$nonce         = $args['_wpnonce'];
41 41
 
42
-	if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) {
43
-		wp_die( esc_html__( 'Cheatin&#8217; uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
42
+	if ( ! wp_verify_nonce($nonce, 'edit-customer')) {
43
+		wp_die(esc_html__('Cheatin&#8217; uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400));
44 44
 	}
45 45
 
46
-	$customer = new Give_Customer( $customer_id );
47
-	if ( empty( $customer->id ) ) {
46
+	$customer = new Give_Customer($customer_id);
47
+	if (empty($customer->id)) {
48 48
 		return false;
49 49
 	}
50 50
 
@@ -54,23 +54,23 @@  discard block
 block discarded – undo
54 54
 		'user_id' => 0
55 55
 	);
56 56
 
57
-	$customer_info = wp_parse_args( $customer_info, $defaults );
57
+	$customer_info = wp_parse_args($customer_info, $defaults);
58 58
 
59
-	if ( ! is_email( $customer_info['email'] ) ) {
60
-		give_set_error( 'give-invalid-email', esc_html__( 'Please enter a valid email address.', 'give' ) );
59
+	if ( ! is_email($customer_info['email'])) {
60
+		give_set_error('give-invalid-email', esc_html__('Please enter a valid email address.', 'give'));
61 61
 	}
62 62
 
63
-	if ( (int) $customer_info['user_id'] != (int) $customer->user_id ) {
63
+	if ((int) $customer_info['user_id'] != (int) $customer->user_id) {
64 64
 
65 65
 		// Make sure we don't already have this user attached to a customer
66
-		if ( ! empty( $customer_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $customer_info['user_id'] ) ) {
67
-			give_set_error( 'give-invalid-customer-user_id', sprintf( esc_html__( 'The User ID %d is already associated with a different donor.', 'give' ), $customer_info['user_id'] ) );
66
+		if ( ! empty($customer_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $customer_info['user_id'])) {
67
+			give_set_error('give-invalid-customer-user_id', sprintf(esc_html__('The User ID %d is already associated with a different donor.', 'give'), $customer_info['user_id']));
68 68
 		}
69 69
 
70 70
 		// Make sure it's actually a user
71
-		$user = get_user_by( 'id', $customer_info['user_id'] );
72
-		if ( ! empty( $customer_info['user_id'] ) && false === $user ) {
73
-			give_set_error( 'give-invalid-user_id', sprintf( esc_html__( 'The User ID %d does not exist. Please assign an existing user.', 'give' ), $customer_info['user_id'] ) );
71
+		$user = get_user_by('id', $customer_info['user_id']);
72
+		if ( ! empty($customer_info['user_id']) && false === $user) {
73
+			give_set_error('give-invalid-user_id', sprintf(esc_html__('The User ID %d does not exist. Please assign an existing user.', 'give'), $customer_info['user_id']));
74 74
 		}
75 75
 
76 76
 	}
@@ -78,53 +78,53 @@  discard block
 block discarded – undo
78 78
 	// Record this for later
79 79
 	$previous_user_id = $customer->user_id;
80 80
 
81
-	if ( give_get_errors() ) {
81
+	if (give_get_errors()) {
82 82
 		return;
83 83
 	}
84 84
 
85 85
 	// Setup the customer address, if present
86 86
 	$address = array();
87
-	if ( intval( $customer_info['user_id'] ) > 0 ) {
87
+	if (intval($customer_info['user_id']) > 0) {
88 88
 
89
-		$current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true );
89
+		$current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true);
90 90
 
91
-		if ( false === $current_address ) {
92
-			$address['line1']   = isset( $customer_info['line1'] ) ? $customer_info['line1'] : '';
93
-			$address['line2']   = isset( $customer_info['line2'] ) ? $customer_info['line2'] : '';
94
-			$address['city']    = isset( $customer_info['city'] ) ? $customer_info['city'] : '';
95
-			$address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : '';
96
-			$address['zip']     = isset( $customer_info['zip'] ) ? $customer_info['zip'] : '';
97
-			$address['state']   = isset( $customer_info['state'] ) ? $customer_info['state'] : '';
91
+		if (false === $current_address) {
92
+			$address['line1']   = isset($customer_info['line1']) ? $customer_info['line1'] : '';
93
+			$address['line2']   = isset($customer_info['line2']) ? $customer_info['line2'] : '';
94
+			$address['city']    = isset($customer_info['city']) ? $customer_info['city'] : '';
95
+			$address['country'] = isset($customer_info['country']) ? $customer_info['country'] : '';
96
+			$address['zip']     = isset($customer_info['zip']) ? $customer_info['zip'] : '';
97
+			$address['state']   = isset($customer_info['state']) ? $customer_info['state'] : '';
98 98
 		} else {
99
-			$current_address    = wp_parse_args( $current_address, array(
99
+			$current_address    = wp_parse_args($current_address, array(
100 100
 				'line1',
101 101
 				'line2',
102 102
 				'city',
103 103
 				'zip',
104 104
 				'state',
105 105
 				'country'
106
-			) );
107
-			$address['line1']   = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1'];
108
-			$address['line2']   = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2'];
109
-			$address['city']    = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city'];
110
-			$address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country'];
111
-			$address['zip']     = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip'];
112
-			$address['state']   = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state'];
106
+			));
107
+			$address['line1']   = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1'];
108
+			$address['line2']   = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2'];
109
+			$address['city']    = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city'];
110
+			$address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country'];
111
+			$address['zip']     = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip'];
112
+			$address['state']   = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state'];
113 113
 		}
114 114
 
115 115
 	}
116 116
 
117 117
 	// Sanitize the inputs
118 118
 	$customer_data            = array();
119
-	$customer_data['name']    = strip_tags( stripslashes( $customer_info['name'] ) );
119
+	$customer_data['name']    = strip_tags(stripslashes($customer_info['name']));
120 120
 	$customer_data['email']   = $customer_info['email'];
121 121
 	$customer_data['user_id'] = $customer_info['user_id'];
122 122
 
123
-	$customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id );
124
-	$address       = apply_filters( 'give_edit_customer_address', $address, $customer_id );
123
+	$customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id);
124
+	$address       = apply_filters('give_edit_customer_address', $address, $customer_id);
125 125
 
126
-	$customer_data = array_map( 'sanitize_text_field', $customer_data );
127
-	$address       = array_map( 'sanitize_text_field', $address );
126
+	$customer_data = array_map('sanitize_text_field', $customer_data);
127
+	$address       = array_map('sanitize_text_field', $address);
128 128
 
129 129
 
130 130
 	/**
@@ -136,34 +136,34 @@  discard block
 block discarded – undo
136 136
 	 * @param array $customer_data The customer data.
137 137
 	 * @param array $address       The customer address.
138 138
 	 */
139
-	do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address );
139
+	do_action('give_pre_edit_customer', $customer_id, $customer_data, $address);
140 140
 
141 141
 	$output         = array();
142 142
 	$previous_email = $customer->email;
143 143
 
144
-	if ( $customer->update( $customer_data ) ) {
144
+	if ($customer->update($customer_data)) {
145 145
 
146
-		if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) {
147
-			update_user_meta( $customer->user_id, '_give_user_address', $address );
146
+		if ( ! empty($customer->user_id) && $customer->user_id > 0) {
147
+			update_user_meta($customer->user_id, '_give_user_address', $address);
148 148
 		}
149 149
 
150 150
 		// Update some donation meta if we need to
151
-		$payments_array = explode( ',', $customer->payment_ids );
151
+		$payments_array = explode(',', $customer->payment_ids);
152 152
 
153
-		if ( $customer->email != $previous_email ) {
154
-			foreach ( $payments_array as $payment_id ) {
155
-				give_update_payment_meta( $payment_id, 'email', $customer->email );
153
+		if ($customer->email != $previous_email) {
154
+			foreach ($payments_array as $payment_id) {
155
+				give_update_payment_meta($payment_id, 'email', $customer->email);
156 156
 			}
157 157
 		}
158 158
 
159
-		if ( $customer->user_id != $previous_user_id ) {
160
-			foreach ( $payments_array as $payment_id ) {
161
-				give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id );
159
+		if ($customer->user_id != $previous_user_id) {
160
+			foreach ($payments_array as $payment_id) {
161
+				give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id);
162 162
 			}
163 163
 		}
164 164
 
165 165
 		$output['success']       = true;
166
-		$customer_data           = array_merge( $customer_data, $address );
166
+		$customer_data           = array_merge($customer_data, $address);
167 167
 		$output['customer_info'] = $customer_data;
168 168
 
169 169
 	} else {
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 	 * @param int   $customer_id   The ID of the customer.
181 181
 	 * @param array $customer_data The customer data.
182 182
 	 */
183
-	do_action( 'give_post_edit_customer', $customer_id, $customer_data );
183
+	do_action('give_post_edit_customer', $customer_id, $customer_data);
184 184
 
185
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
186
-		header( 'Content-Type: application/json' );
187
-		echo json_encode( $output );
185
+	if (defined('DOING_AJAX') && DOING_AJAX) {
186
+		header('Content-Type: application/json');
187
+		echo json_encode($output);
188 188
 		wp_die();
189 189
 	}
190 190
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 }
194 194
 
195
-add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 );
195
+add_action('give_edit-customer', 'give_edit_customer', 10, 1);
196 196
 
197 197
 /**
198 198
  * Save a customer note being added
@@ -203,36 +203,36 @@  discard block
 block discarded – undo
203 203
  *
204 204
  * @return int         The Note ID that was saved, or 0 if nothing was saved
205 205
  */
206
-function give_customer_save_note( $args ) {
206
+function give_customer_save_note($args) {
207 207
 
208
-	$customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' );
208
+	$customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports');
209 209
 
210
-	if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) {
211
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
210
+	if ( ! is_admin() || ! current_user_can($customer_view_role)) {
211
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
212 212
 	}
213 213
 
214
-	if ( empty( $args ) ) {
214
+	if (empty($args)) {
215 215
 		return;
216 216
 	}
217 217
 
218
-	$customer_note = trim( sanitize_text_field( $args['customer_note'] ) );
218
+	$customer_note = trim(sanitize_text_field($args['customer_note']));
219 219
 	$customer_id   = (int) $args['customer_id'];
220 220
 	$nonce         = $args['add_customer_note_nonce'];
221 221
 
222
-	if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) {
223
-		wp_die( esc_html__( 'Cheatin&#8217; uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
222
+	if ( ! wp_verify_nonce($nonce, 'add-customer-note')) {
223
+		wp_die(esc_html__('Cheatin&#8217; uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400));
224 224
 	}
225 225
 
226
-	if ( empty( $customer_note ) ) {
227
-		give_set_error( 'empty-customer-note', esc_html__( 'A note is required.', 'give' ) );
226
+	if (empty($customer_note)) {
227
+		give_set_error('empty-customer-note', esc_html__('A note is required.', 'give'));
228 228
 	}
229 229
 
230
-	if ( give_get_errors() ) {
230
+	if (give_get_errors()) {
231 231
 		return;
232 232
 	}
233 233
 
234
-	$customer = new Give_Customer( $customer_id );
235
-	$new_note = $customer->add_note( $customer_note );
234
+	$customer = new Give_Customer($customer_id);
235
+	$new_note = $customer->add_note($customer_note);
236 236
 
237 237
 	/**
238 238
 	 * Fires before inserting customer note.
@@ -242,22 +242,22 @@  discard block
 block discarded – undo
242 242
 	 * @param int    $customer_id The ID of the customer.
243 243
 	 * @param string $new_note    Note content.
244 244
 	 */
245
-	do_action( 'give_pre_insert_customer_note', $customer_id, $new_note );
245
+	do_action('give_pre_insert_customer_note', $customer_id, $new_note);
246 246
 
247
-	if ( ! empty( $new_note ) && ! empty( $customer->id ) ) {
247
+	if ( ! empty($new_note) && ! empty($customer->id)) {
248 248
 
249 249
 		ob_start();
250 250
 		?>
251 251
 		<div class="customer-note-wrapper dashboard-comment-wrap comment-item">
252 252
 			<span class="note-content-wrap">
253
-				<?php echo stripslashes( $new_note ); ?>
253
+				<?php echo stripslashes($new_note); ?>
254 254
 			</span>
255 255
 		</div>
256 256
 		<?php
257 257
 		$output = ob_get_contents();
258 258
 		ob_end_clean();
259 259
 
260
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
260
+		if (defined('DOING_AJAX') && DOING_AJAX) {
261 261
 			echo $output;
262 262
 			exit;
263 263
 		}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 
271 271
 }
272 272
 
273
-add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 );
273
+add_action('give_add-customer-note', 'give_customer_save_note', 10, 1);
274 274
 
275 275
 /**
276 276
  * Delete a customer
@@ -281,37 +281,37 @@  discard block
 block discarded – undo
281 281
  *
282 282
  * @return int Whether it was a successful deletion
283 283
  */
284
-function give_customer_delete( $args ) {
284
+function give_customer_delete($args) {
285 285
 
286
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
286
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
287 287
 
288
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
289
-		wp_die( esc_html__( 'You do not have permission to delete donors.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
288
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
289
+		wp_die(esc_html__('You do not have permission to delete donors.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
290 290
 	}
291 291
 
292
-	if ( empty( $args ) ) {
292
+	if (empty($args)) {
293 293
 		return;
294 294
 	}
295 295
 
296 296
 	$customer_id = (int) $args['customer_id'];
297
-	$confirm     = ! empty( $args['give-customer-delete-confirm'] ) ? true : false;
298
-	$remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false;
297
+	$confirm     = ! empty($args['give-customer-delete-confirm']) ? true : false;
298
+	$remove_data = ! empty($args['give-customer-delete-records']) ? true : false;
299 299
 	$nonce       = $args['_wpnonce'];
300 300
 
301
-	if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) {
302
-		wp_die( esc_html__( 'Cheatin&#8217; uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
301
+	if ( ! wp_verify_nonce($nonce, 'delete-customer')) {
302
+		wp_die(esc_html__('Cheatin&#8217; uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400));
303 303
 	}
304 304
 
305
-	if ( ! $confirm ) {
306
-		give_set_error( 'customer-delete-no-confirm', esc_html__( 'Please confirm you want to delete this donor.', 'give' ) );
305
+	if ( ! $confirm) {
306
+		give_set_error('customer-delete-no-confirm', esc_html__('Please confirm you want to delete this donor.', 'give'));
307 307
 	}
308 308
 
309
-	if ( give_get_errors() ) {
310
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) );
309
+	if (give_get_errors()) {
310
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id));
311 311
 		exit;
312 312
 	}
313 313
 
314
-	$customer = new Give_Customer( $customer_id );
314
+	$customer = new Give_Customer($customer_id);
315 315
 
316 316
 	/**
317 317
 	 * Fires before deleting customer.
@@ -322,53 +322,53 @@  discard block
 block discarded – undo
322 322
 	 * @param bool $confirm     Delete confirmation.
323 323
 	 * @param bool $remove_data Records delete confirmation.
324 324
 	 */
325
-	do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data );
325
+	do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data);
326 326
 	
327
-	if ( $customer->id > 0 ) {
327
+	if ($customer->id > 0) {
328 328
 
329
-		$payments_array = explode( ',', $customer->payment_ids );
330
-		$success        = Give()->customers->delete( $customer->id );
329
+		$payments_array = explode(',', $customer->payment_ids);
330
+		$success        = Give()->customers->delete($customer->id);
331 331
 
332
-		if ( $success ) {
332
+		if ($success) {
333 333
 
334
-			if ( $remove_data ) {
334
+			if ($remove_data) {
335 335
 
336 336
 				// Remove all donations, logs, etc
337
-				foreach ( $payments_array as $payment_id ) {
338
-					give_delete_purchase( $payment_id );
337
+				foreach ($payments_array as $payment_id) {
338
+					give_delete_purchase($payment_id);
339 339
 				}
340 340
 
341 341
 			} else {
342 342
 
343 343
 				// Just set the donations to customer_id of 0
344
-				foreach ( $payments_array as $payment_id ) {
345
-					give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 );
344
+				foreach ($payments_array as $payment_id) {
345
+					give_update_payment_meta($payment_id, '_give_payment_customer_id', 0);
346 346
 				}
347 347
 
348 348
 			}
349 349
 
350
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' );
350
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted');
351 351
 
352 352
 		} else {
353 353
 
354
-			give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) );
355
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id );
354
+			give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give'));
355
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id);
356 356
 
357 357
 		}
358 358
 
359 359
 	} else {
360 360
 
361
-		give_set_error( 'give-customer-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) );
362
-		$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' );
361
+		give_set_error('give-customer-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give'));
362
+		$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors');
363 363
 
364 364
 	}
365 365
 
366
-	wp_redirect( $redirect );
366
+	wp_redirect($redirect);
367 367
 	exit;
368 368
 
369 369
 }
370 370
 
371
-add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 );
371
+add_action('give_delete-customer', 'give_customer_delete', 10, 1);
372 372
 
373 373
 /**
374 374
  * Disconnect a user ID from a donor
@@ -379,27 +379,27 @@  discard block
 block discarded – undo
379 379
  *
380 380
  * @return bool        If the disconnect was successful
381 381
  */
382
-function give_disconnect_customer_user_id( $args ) {
382
+function give_disconnect_customer_user_id($args) {
383 383
 
384
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
384
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
385 385
 
386
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
387
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
386
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
387
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
388 388
 	}
389 389
 
390
-	if ( empty( $args ) ) {
390
+	if (empty($args)) {
391 391
 		return;
392 392
 	}
393 393
 
394 394
 	$customer_id = (int) $args['customer_id'];
395 395
 	$nonce       = $args['_wpnonce'];
396 396
 
397
-	if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) {
398
-		wp_die( esc_html__( 'Cheatin&#8217; uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
397
+	if ( ! wp_verify_nonce($nonce, 'edit-customer')) {
398
+		wp_die(esc_html__('Cheatin&#8217; uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400));
399 399
 	}
400 400
 
401
-	$customer = new Give_Customer( $customer_id );
402
-	if ( empty( $customer->id ) ) {
401
+	$customer = new Give_Customer($customer_id);
402
+	if (empty($customer->id)) {
403 403
 		return false;
404 404
 	}
405 405
 
@@ -413,16 +413,16 @@  discard block
 block discarded – undo
413 413
 	 * @param int $customer_id The ID of the customer.
414 414
 	 * @param int $user_id     The ID of the user.
415 415
 	 */
416
-	do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $user_id );
416
+	do_action('give_pre_customer_disconnect_user_id', $customer_id, $user_id);
417 417
 
418 418
 	$output = array();
419
-	$customer_args = array( 'user_id' => 0 );
419
+	$customer_args = array('user_id' => 0);
420 420
 
421
-	if ( $customer->update( $customer_args ) ) {
421
+	if ($customer->update($customer_args)) {
422 422
 		global $wpdb;
423 423
 
424
-		if ( ! empty( $customer->payment_ids ) ) {
425
-			$wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" );
424
+		if ( ! empty($customer->payment_ids)) {
425
+			$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )");
426 426
 		}
427 427
 
428 428
 		$output['success'] = true;
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 	} else {
431 431
 
432 432
 		$output['success'] = false;
433
-		give_set_error( 'give-disconnect-user-fail', esc_html__( 'Failed to disconnect user from donor.', 'give' ) );
433
+		give_set_error('give-disconnect-user-fail', esc_html__('Failed to disconnect user from donor.', 'give'));
434 434
 	}
435 435
 
436 436
 	/**
@@ -440,11 +440,11 @@  discard block
 block discarded – undo
440 440
 	 *
441 441
 	 * @param int $customer_id The ID of the customer.
442 442
 	 */
443
-	do_action( 'give_post_customer_disconnect_user_id', $customer_id );
443
+	do_action('give_post_customer_disconnect_user_id', $customer_id);
444 444
 
445
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
446
-		header( 'Content-Type: application/json' );
447
-		echo json_encode( $output );
445
+	if (defined('DOING_AJAX') && DOING_AJAX) {
446
+		header('Content-Type: application/json');
447
+		echo json_encode($output);
448 448
 		wp_die();
449 449
 	}
450 450
 
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 
453 453
 }
454 454
 
455
-add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 );
455
+add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1);
456 456
 
457 457
 /**
458 458
  * Add an email address to the donor from within the admin and log a donor note
@@ -461,81 +461,81 @@  discard block
 block discarded – undo
461 461
  * @param  array $args  Array of arguments: nonce, customer id, and email address
462 462
  * @return mixed        If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string)
463 463
  */
464
-function give_add_donor_email( $args ) {
465
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
464
+function give_add_donor_email($args) {
465
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
466 466
 
467
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
468
-		wp_die( __( 'You do not have permission to edit this donor.', 'edit' ) );
467
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
468
+		wp_die(__('You do not have permission to edit this donor.', 'edit'));
469 469
 	}
470 470
 
471 471
 	$output = array();
472
-	if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) {
472
+	if (empty($args) || empty($args['email']) || empty($args['customer_id'])) {
473 473
 		$output['success'] = false;
474
-		if ( empty( $args['email'] ) ) {
475
-			$output['message'] = __( 'Email address is required.', 'give' );
476
-		} else if ( empty( $args['customer_id'] ) ) {
477
-			$output['message'] = __( 'Customer ID is required.', 'give' );
474
+		if (empty($args['email'])) {
475
+			$output['message'] = __('Email address is required.', 'give');
476
+		} else if (empty($args['customer_id'])) {
477
+			$output['message'] = __('Customer ID is required.', 'give');
478 478
 		} else {
479
-			$output['message'] = __( 'An error has occurred. Please try again.', 'give' );
479
+			$output['message'] = __('An error has occurred. Please try again.', 'give');
480 480
 		}
481
-	} else if ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) {
481
+	} else if ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) {
482 482
 		$output = array(
483 483
 			'success' => false,
484
-			'message' => __( 'Nonce verification failed.', 'give' ),
484
+			'message' => __('Nonce verification failed.', 'give'),
485 485
 		);
486
-	} else if ( ! is_email( $args['email'] ) ) {
486
+	} else if ( ! is_email($args['email'])) {
487 487
 		$output = array(
488 488
 			'success' => false,
489
-			'message' => __( 'Invalid email address.', 'give' ),
489
+			'message' => __('Invalid email address.', 'give'),
490 490
 		);
491 491
 	} else {
492
-		$email       = sanitize_email($args['email'] );
492
+		$email       = sanitize_email($args['email']);
493 493
 		$customer_id = (int) $args['customer_id'];
494 494
 		$primary     = 'true' === $args['primary'] ? true : false;
495
-		$customer    = new Give_Customer( $customer_id );
496
-		if ( false === $customer->add_email( $email, $primary ) ) {
497
-			if ( in_array( $email, $customer->emails ) ) {
495
+		$customer    = new Give_Customer($customer_id);
496
+		if (false === $customer->add_email($email, $primary)) {
497
+			if (in_array($email, $customer->emails)) {
498 498
 				$output = array(
499 499
 					'success'  => false,
500
-					'message'  => __( 'Email already associated with this donor.', 'give' ),
500
+					'message'  => __('Email already associated with this donor.', 'give'),
501 501
 				);
502 502
 			} else {
503 503
 				$output = array(
504 504
 					'success' => false,
505
-					'message' => __( 'Email address is already associated with another donor.', 'give' ),
505
+					'message' => __('Email address is already associated with another donor.', 'give'),
506 506
 				);
507 507
 			}
508 508
 		} else {
509
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id . '&give-message=email-added' );
509
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id.'&give-message=email-added');
510 510
 			$output = array(
511 511
 				'success'  => true,
512
-				'message'  => __( 'Email successfully added to donor.', 'give' ),
512
+				'message'  => __('Email successfully added to donor.', 'give'),
513 513
 				'redirect' => $redirect,
514 514
 			);
515 515
 
516 516
 			$user          = wp_get_current_user();
517
-			$user_login    = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' );
518
-			$customer_note = __( sprintf( 'Email address %s added by %s', $email, $user_login ), 'give' );
519
-			$customer->add_note( $customer_note );
517
+			$user_login    = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give');
518
+			$customer_note = __(sprintf('Email address %s added by %s', $email, $user_login), 'give');
519
+			$customer->add_note($customer_note);
520 520
 
521
-			if ( $primary ) {
522
-				$customer_note = __( sprintf( 'Email address %s set as primary by %s', $email, $user_login ), 'give' );
523
-				$customer->add_note( $customer_note );
521
+			if ($primary) {
522
+				$customer_note = __(sprintf('Email address %s set as primary by %s', $email, $user_login), 'give');
523
+				$customer->add_note($customer_note);
524 524
 			}
525 525
 		}
526 526
 	}
527 527
 
528
-	do_action( 'give_post_add_customer_email', $customer_id, $args );
528
+	do_action('give_post_add_customer_email', $customer_id, $args);
529 529
 
530
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
531
-		header( 'Content-Type: application/json' );
532
-		echo json_encode( $output );
530
+	if (defined('DOING_AJAX') && DOING_AJAX) {
531
+		header('Content-Type: application/json');
532
+		echo json_encode($output);
533 533
 		wp_die();
534 534
 	}
535 535
 
536 536
 	return $output;
537 537
 }
538
-add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 );
538
+add_action('give_add_donor_email', 'give_add_donor_email', 10, 1);
539 539
 
540 540
 
541 541
 /**
@@ -546,36 +546,36 @@  discard block
 block discarded – undo
546 546
  * @return void|bool
547 547
  */
548 548
 function give_remove_donor_email() {
549
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
549
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
550 550
 		return false;
551 551
 	}
552
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
552
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
553 553
 		return false;
554 554
 	}
555
-	if ( empty( $_GET['_wpnonce'] ) ) {
555
+	if (empty($_GET['_wpnonce'])) {
556 556
 		return false;
557 557
 	}
558 558
 
559 559
 	$nonce = $_GET['_wpnonce'];
560
-	if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) {
561
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
560
+	if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) {
561
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array('response' => 403));
562 562
 	}
563 563
 
564
-	$customer = new Give_Customer( $_GET['id'] );
565
-	if ( $customer->remove_email( $_GET['email'] ) ) {
566
-		$url = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ) );
564
+	$customer = new Give_Customer($_GET['id']);
565
+	if ($customer->remove_email($_GET['email'])) {
566
+		$url = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id));
567 567
 		$user          = wp_get_current_user();
568
-		$user_login    = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' );
569
-		$customer_note = __( sprintf( 'Email address %s removed by %s', $_GET['email'], $user_login ), 'give' );
570
-		$customer->add_note( $customer_note );
568
+		$user_login    = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give');
569
+		$customer_note = __(sprintf('Email address %s removed by %s', $_GET['email'], $user_login), 'give');
570
+		$customer->add_note($customer_note);
571 571
 	} else {
572
-		$url = add_query_arg( 'give-message', 'email-remove-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ) );
572
+		$url = add_query_arg('give-message', 'email-remove-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id));
573 573
 	}
574 574
 
575
-	wp_safe_redirect( $url );
575
+	wp_safe_redirect($url);
576 576
 	exit;
577 577
 }
578
-add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 );
578
+add_action('give_remove_donor_email', 'give_remove_donor_email', 10);
579 579
 
580 580
 
581 581
 /**
@@ -586,38 +586,38 @@  discard block
 block discarded – undo
586 586
  * @return void|bool
587 587
  */
588 588
 function give_set_donor_primary_email() {
589
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
589
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
590 590
 		return false;
591 591
 	}
592 592
 
593
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
593
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
594 594
 		return false;
595 595
 	}
596 596
 
597
-	if ( empty( $_GET['_wpnonce'] ) ) {
597
+	if (empty($_GET['_wpnonce'])) {
598 598
 		return false;
599 599
 	}
600 600
 
601 601
 	$nonce = $_GET['_wpnonce'];
602 602
 
603
-	if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) {
604
-		wp_die( __( 'Nonce verification failed', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
603
+	if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) {
604
+		wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array('response' => 403));
605 605
 	}
606 606
 
607
-	$donor = new Give_Customer( $_GET['id'] );
607
+	$donor = new Give_Customer($_GET['id']);
608 608
 
609
-	if ( $donor->set_primary_email( $_GET['email'] ) ) {
610
-		$url = add_query_arg( 'give-message', 'primary-email-updated', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
609
+	if ($donor->set_primary_email($_GET['email'])) {
610
+		$url = add_query_arg('give-message', 'primary-email-updated', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
611 611
 		$user          = wp_get_current_user();
612
-		$user_login    = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' );
613
-		$donor_note    = __( sprintf( 'Email address %s set as primary by %s', $_GET['email'], $user_login ), 'give' );
612
+		$user_login    = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give');
613
+		$donor_note    = __(sprintf('Email address %s set as primary by %s', $_GET['email'], $user_login), 'give');
614 614
 
615
-		$donor->add_note( $donor_note );
615
+		$donor->add_note($donor_note);
616 616
 	} else {
617
-		$url = add_query_arg( 'give-message', 'primary-email-failed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ) );
617
+		$url = add_query_arg('give-message', 'primary-email-failed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id));
618 618
 	}
619 619
 
620
-	wp_safe_redirect( $url );
620
+	wp_safe_redirect($url);
621 621
 	exit;
622 622
 }
623
-add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 );
623
+add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10);
Please login to merge, or discard this patch.
includes/class-give-customer.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 	 * @access public
891 891
 	 *
892 892
 	 * @param  string $meta_key   Metadata name. Default is empty.
893
-	 * @param  mixed  $meta_value Metadata value.
893
+	 * @param  string  $meta_value Metadata value.
894 894
 	 * @param  bool   $unique     Optional. Whether the same key should not be added. Default is false.
895 895
 	 *
896 896
 	 * @return bool               False for failure. True for success.
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
 	 * @access public
923 923
 	 *
924 924
 	 * @param  string $meta_key   Metadata name. Default is empty.
925
-	 * @param  mixed  $meta_value Optional. Metadata value. Default is empty.
925
+	 * @param  string  $meta_value Optional. Metadata value. Default is empty.
926 926
 	 *
927 927
 	 * @return bool               False for failure. True for success.
928 928
 	 */
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -714,12 +714,12 @@  discard block
 block discarded – undo
714 714
 
715 715
 	/**
716 716
 	 * Decrease/Increase a customer's lifetime value.
717
-     *
718
-     * This function will update donation stat on basis of current amount and new amount donation difference.
719
-     * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat.
720
-     *
717
+	 *
718
+	 * This function will update donation stat on basis of current amount and new amount donation difference.
719
+	 * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat.
720
+	 *
721 721
 	 * @since  1.0
722
-     * @access public
722
+	 * @access public
723 723
 	 *
724 724
 	 * @param  float $curr_amount Current Donation amount.
725 725
 	 * @param  float $new_amount  New (changed) Donation amount.
@@ -727,35 +727,35 @@  discard block
 block discarded – undo
727 727
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
728 728
 	 */
729 729
 	public function update_donation_value( $curr_amount, $new_amount ) {
730
-        /**
731
-         * Payment total difference value can be:
732
-         *  zero   (in case amount not change)
733
-         *  or -ve (in case amount decrease)
734
-         *  or +ve (in case amount increase)
735
-         */
736
-        $payment_total_diff = $new_amount - $curr_amount;
737
-
738
-        // We do not need to update donation stat if donation did not change.
739
-        if( ! $payment_total_diff ) {
740
-            return false;
741
-        }
742
-
743
-
744
-        if( $payment_total_diff > 0 ) {
745
-            $this->increase_value( $payment_total_diff );
746
-        } else {
747
-            // Pass payment total difference as +ve value to decrease amount from user lifetime stat.
748
-            $this->decrease_value( -$payment_total_diff );
749
-        }
750
-
751
-        return $this->purchase_value;
730
+		/**
731
+		 * Payment total difference value can be:
732
+		 *  zero   (in case amount not change)
733
+		 *  or -ve (in case amount decrease)
734
+		 *  or +ve (in case amount increase)
735
+		 */
736
+		$payment_total_diff = $new_amount - $curr_amount;
737
+
738
+		// We do not need to update donation stat if donation did not change.
739
+		if( ! $payment_total_diff ) {
740
+			return false;
741
+		}
742
+
743
+
744
+		if( $payment_total_diff > 0 ) {
745
+			$this->increase_value( $payment_total_diff );
746
+		} else {
747
+			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
748
+			$this->decrease_value( -$payment_total_diff );
749
+		}
750
+
751
+		return $this->purchase_value;
752 752
 	}
753 753
 
754 754
 	/**
755 755
 	 * Get the parsed notes for a customer as an array.
756 756
 	 *
757 757
 	 * @since  1.0
758
-     * @access public
758
+	 * @access public
759 759
 	 *
760 760
 	 * @param  int $length The number of notes to get.
761 761
 	 * @param  int $paged  What note to start at.
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 	 * Get the total number of notes we have after parsing.
781 781
 	 *
782 782
 	 * @since  1.0
783
-     * @access public
783
+	 * @access public
784 784
 	 *
785 785
 	 * @return int The number of notes for the customer.
786 786
 	 */
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
 	 * Add a note for the customer.
798 798
 	 *
799 799
 	 * @since  1.0
800
-     * @access public
800
+	 * @access public
801 801
 	 *
802 802
 	 * @param  string $note   The note to add. Default is empty.
803 803
 	 *
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
 	 * Get the notes column for the customer
857 857
 	 *
858 858
 	 * @since  1.0
859
-     * @access private
859
+	 * @access private
860 860
 	 *
861 861
 	 * @return string The Notes for the customer, non-parsed.
862 862
 	 */
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 	 * Sanitize the data for update/create
935 935
 	 *
936 936
 	 * @since  1.0
937
-     * @access private
937
+	 * @access private
938 938
 	 *
939 939
 	 * @param  array $data The data to sanitize.
940 940
 	 *
Please login to merge, or discard this patch.
Spacing   +169 added lines, -169 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
 
@@ -144,29 +144,29 @@  discard block
 block discarded – undo
144 144
 	 * @param  bool $_id_or_email 
145 145
 	 * @param  bool $by_user_id
146 146
 	 */
147
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
147
+	public function __construct($_id_or_email = false, $by_user_id = false) {
148 148
 
149 149
 		$this->db = new Give_DB_Customers;
150 150
 
151
-		if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) {
151
+		if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) {
152 152
 			return false;
153 153
 		}
154 154
 
155
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
155
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
156 156
 
157
-		if ( is_numeric( $_id_or_email ) ) {
157
+		if (is_numeric($_id_or_email)) {
158 158
 			$field = $by_user_id ? 'user_id' : 'id';
159 159
 		} else {
160 160
 			$field = 'email';
161 161
 		}
162 162
 
163
-		$customer = $this->db->get_customer_by( $field, $_id_or_email );
163
+		$customer = $this->db->get_customer_by($field, $_id_or_email);
164 164
 
165
-		if ( empty( $customer ) || ! is_object( $customer ) ) {
165
+		if (empty($customer) || ! is_object($customer)) {
166 166
 			return false;
167 167
 		}
168 168
 
169
-		$this->setup_customer( $customer );
169
+		$this->setup_customer($customer);
170 170
 
171 171
 	}
172 172
 
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @return bool             If the setup was successful or not.
184 184
 	 */
185
-	private function setup_customer( $customer ) {
185
+	private function setup_customer($customer) {
186 186
 
187
-		if ( ! is_object( $customer ) ) {
187
+		if ( ! is_object($customer)) {
188 188
 			return false;
189 189
 		}
190 190
 
191
-		foreach ( $customer as $key => $value ) {
191
+		foreach ($customer as $key => $value) {
192 192
 
193
-			switch ( $key ) {
193
+			switch ($key) {
194 194
 
195 195
 				case 'notes':
196 196
 					$this->$key = $this->get_notes();
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 		}
206 206
 
207 207
 		// Get donor's all email including primary email.
208
-		$this->emails   = (array) $this->get_meta( 'additional_email', false );
209
-		$this->emails = array( 'primary' => $this->email ) + $this->emails;
208
+		$this->emails = (array) $this->get_meta('additional_email', false);
209
+		$this->emails = array('primary' => $this->email) + $this->emails;
210 210
 
211 211
 		// Customer ID and email are the only things that are necessary, make sure they exist.
212
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
212
+		if ( ! empty($this->id) && ! empty($this->email)) {
213 213
 			return true;
214 214
 		}
215 215
 
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
 	 * @since  1.0
224 224
 	 * @access public
225 225
 	 */
226
-	public function __get( $key ) {
226
+	public function __get($key) {
227 227
 
228
-		if ( method_exists( $this, 'get_' . $key ) ) {
228
+		if (method_exists($this, 'get_'.$key)) {
229 229
 
230
-			return call_user_func( array( $this, 'get_' . $key ) );
230
+			return call_user_func(array($this, 'get_'.$key));
231 231
 
232 232
 		} else {
233 233
 
234 234
 			/* translators: %s: property key */
235
-			return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
235
+			return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
236 236
 
237 237
 		}
238 238
 
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return bool|int    False if not a valid creation, customer ID if user is found or valid creation.
250 250
 	 */
251
-	public function create( $data = array() ) {
251
+	public function create($data = array()) {
252 252
 
253
-		if ( $this->id != 0 || empty( $data ) ) {
253
+		if ($this->id != 0 || empty($data)) {
254 254
 			return false;
255 255
 		}
256 256
 
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
 			'payment_ids' => ''
259 259
 		);
260 260
 
261
-		$args = wp_parse_args( $data, $defaults );
262
-		$args = $this->sanitize_columns( $args );
261
+		$args = wp_parse_args($data, $defaults);
262
+		$args = $this->sanitize_columns($args);
263 263
 
264
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
264
+		if (empty($args['email']) || ! is_email($args['email'])) {
265 265
 			return false;
266 266
 		}
267 267
 
268
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
269
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
268
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
269
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
270 270
 		}
271 271
 
272 272
 		/**
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
 		 *
277 277
 		 * @param array $args Customer attributes.
278 278
 		 */
279
-		do_action( 'give_customer_pre_create', $args );
279
+		do_action('give_customer_pre_create', $args);
280 280
 
281 281
 		$created = false;
282 282
 
283 283
 		// The DB class 'add' implies an update if the customer being asked to be created already exists
284
-		if ( $this->db->add( $data ) ) {
284
+		if ($this->db->add($data)) {
285 285
 
286 286
 			// We've successfully added/updated the customer, reset the class vars with the new data
287
-			$customer = $this->db->get_customer_by( 'email', $args['email'] );
287
+			$customer = $this->db->get_customer_by('email', $args['email']);
288 288
 
289 289
 			// Setup the customer data with the values from DB
290
-			$this->setup_customer( $customer );
290
+			$this->setup_customer($customer);
291 291
 
292 292
 			$created = $this->id;
293 293
 		}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 		 *                          customer ID if user is found or valid creation.
302 302
 		 * @param array    $args    Customer attributes.
303 303
 		 */
304
-		do_action( 'give_customer_post_create', $created, $args );
304
+		do_action('give_customer_post_create', $created, $args);
305 305
 
306 306
 		return $created;
307 307
 
@@ -317,13 +317,13 @@  discard block
 block discarded – undo
317 317
 	 *
318 318
 	 * @return bool        If the update was successful or not.
319 319
 	 */
320
-	public function update( $data = array() ) {
320
+	public function update($data = array()) {
321 321
 
322
-		if ( empty( $data ) ) {
322
+		if (empty($data)) {
323 323
 			return false;
324 324
 		}
325 325
 
326
-		$data = $this->sanitize_columns( $data );
326
+		$data = $this->sanitize_columns($data);
327 327
 
328 328
 		/**
329 329
 		 * Fires before updating customers.
@@ -333,14 +333,14 @@  discard block
 block discarded – undo
333 333
 		 * @param int   $customer_id Customer id.
334 334
 		 * @param array $data        Customer attributes.
335 335
 		 */
336
-		do_action( 'give_customer_pre_update', $this->id, $data );
336
+		do_action('give_customer_pre_update', $this->id, $data);
337 337
 
338 338
 		$updated = false;
339 339
 
340
-		if ( $this->db->update( $this->id, $data ) ) {
340
+		if ($this->db->update($this->id, $data)) {
341 341
 
342
-			$customer = $this->db->get_customer_by( 'id', $this->id );
343
-			$this->setup_customer( $customer );
342
+			$customer = $this->db->get_customer_by('id', $this->id);
343
+			$this->setup_customer($customer);
344 344
 
345 345
 			$updated = true;
346 346
 		}
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 		 * @param int   $customer_id Customer id.
355 355
 		 * @param array $data        Customer attributes.
356 356
 		 */
357
-		do_action( 'give_customer_post_update', $updated, $this->id, $data );
357
+		do_action('give_customer_post_update', $updated, $this->id, $data);
358 358
 
359 359
 		return $updated;
360 360
 	}
@@ -372,27 +372,27 @@  discard block
 block discarded – undo
372 372
 	 *
373 373
 	 * @return bool            If the attachment was successfuly.
374 374
 	 */
375
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
375
+	public function attach_payment($payment_id = 0, $update_stats = true) {
376 376
 
377
-		if ( empty( $payment_id ) ) {
377
+		if (empty($payment_id)) {
378 378
 			return false;
379 379
 		}
380 380
 
381
-		if ( empty( $this->payment_ids ) ) {
381
+		if (empty($this->payment_ids)) {
382 382
 
383 383
 			$new_payment_ids = $payment_id;
384 384
 
385 385
 		} else {
386 386
 
387
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
387
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
388 388
 
389
-			if ( in_array( $payment_id, $payment_ids ) ) {
389
+			if (in_array($payment_id, $payment_ids)) {
390 390
 				$update_stats = false;
391 391
 			}
392 392
 
393 393
 			$payment_ids[] = $payment_id;
394 394
 
395
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
395
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
396 396
 
397 397
 		}
398 398
 
@@ -404,20 +404,20 @@  discard block
 block discarded – undo
404 404
 		 * @param int $payment_id  Payment id.
405 405
 		 * @param int $customer_id Customer id.
406 406
 		 */
407
-		do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id );
407
+		do_action('give_customer_pre_attach_payment', $payment_id, $this->id);
408 408
 
409
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
409
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
410 410
 
411
-		if ( $payment_added ) {
411
+		if ($payment_added) {
412 412
 
413 413
 			$this->payment_ids = $new_payment_ids;
414 414
 
415 415
 			// We added this payment successfully, increment the stats
416
-			if ( $update_stats ) {
417
-				$payment_amount = give_get_payment_amount( $payment_id );
416
+			if ($update_stats) {
417
+				$payment_amount = give_get_payment_amount($payment_id);
418 418
 
419
-				if ( ! empty( $payment_amount ) ) {
420
-					$this->increase_value( $payment_amount );
419
+				if ( ! empty($payment_amount)) {
420
+					$this->increase_value($payment_amount);
421 421
 				}
422 422
 
423 423
 				$this->increase_purchase_count();
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 		 * @param int  $payment_id    Payment id.
435 435
 		 * @param int  $customer_id   Customer id.
436 436
 		 */
437
-		do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id );
437
+		do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id);
438 438
 
439 439
 		return $payment_added;
440 440
 	}
@@ -452,33 +452,33 @@  discard block
 block discarded – undo
452 452
 	 *
453 453
 	 * @return boolean               If the removal was successful.
454 454
 	 */
455
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
455
+	public function remove_payment($payment_id = 0, $update_stats = true) {
456 456
 
457
-		if ( empty( $payment_id ) ) {
457
+		if (empty($payment_id)) {
458 458
 			return false;
459 459
 		}
460 460
 
461
-		$payment = new Give_Payment( $payment_id );
461
+		$payment = new Give_Payment($payment_id);
462 462
 
463
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
463
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
464 464
 			$update_stats = false;
465 465
 		}
466 466
 
467 467
 		$new_payment_ids = '';
468 468
 
469
-		if ( ! empty( $this->payment_ids ) ) {
469
+		if ( ! empty($this->payment_ids)) {
470 470
 
471
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
471
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
472 472
 
473
-			$pos = array_search( $payment_id, $payment_ids );
474
-			if ( false === $pos ) {
473
+			$pos = array_search($payment_id, $payment_ids);
474
+			if (false === $pos) {
475 475
 				return false;
476 476
 			}
477 477
 
478
-			unset( $payment_ids[ $pos ] );
479
-			$payment_ids = array_filter( $payment_ids );
478
+			unset($payment_ids[$pos]);
479
+			$payment_ids = array_filter($payment_ids);
480 480
 
481
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
481
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
482 482
 
483 483
 		}
484 484
 
@@ -490,20 +490,20 @@  discard block
 block discarded – undo
490 490
 		 * @param int $payment_id  Payment id.
491 491
 		 * @param int $customer_id Customer id.
492 492
 		 */
493
-		do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id );
493
+		do_action('give_customer_pre_remove_payment', $payment_id, $this->id);
494 494
 
495
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
495
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
496 496
 
497
-		if ( $payment_removed ) {
497
+		if ($payment_removed) {
498 498
 
499 499
 			$this->payment_ids = $new_payment_ids;
500 500
 
501
-			if ( $update_stats ) {
501
+			if ($update_stats) {
502 502
 				// We removed this payment successfully, decrement the stats
503
-				$payment_amount = give_get_payment_amount( $payment_id );
503
+				$payment_amount = give_get_payment_amount($payment_id);
504 504
 
505
-				if ( ! empty( $payment_amount ) ) {
506
-					$this->decrease_value( $payment_amount );
505
+				if ( ! empty($payment_amount)) {
506
+					$this->decrease_value($payment_amount);
507 507
 				}
508 508
 
509 509
 				$this->decrease_purchase_count();
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 		 * @param int  $payment_id      Payment id.
521 521
 		 * @param int  $customer_id     Customer id.
522 522
 		 */
523
-		do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id );
523
+		do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id);
524 524
 
525 525
 		return $payment_removed;
526 526
 
@@ -536,10 +536,10 @@  discard block
 block discarded – undo
536 536
 	 *
537 537
 	 * @return int        The donation count.
538 538
 	 */
539
-	public function increase_purchase_count( $count = 1 ) {
539
+	public function increase_purchase_count($count = 1) {
540 540
 
541 541
 		// Make sure it's numeric and not negative.
542
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
542
+		if ( ! is_numeric($count) || $count != absint($count)) {
543 543
 			return false;
544 544
 		}
545 545
 
@@ -553,9 +553,9 @@  discard block
 block discarded – undo
553 553
 		 * @param int $count       The number to increase by.
554 554
 		 * @param int $customer_id Customer id.
555 555
 		 */
556
-		do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id );
556
+		do_action('give_customer_pre_increase_purchase_count', $count, $this->id);
557 557
 
558
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
558
+		if ($this->update(array('purchase_count' => $new_total))) {
559 559
 			$this->purchase_count = $new_total;
560 560
 		}
561 561
 
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 		 * @param int $count          The number increased by.
569 569
 		 * @param int $customer_id    Customer id.
570 570
 		 */
571
-		do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id );
571
+		do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id);
572 572
 
573 573
 		return $this->purchase_count;
574 574
 	}
@@ -583,16 +583,16 @@  discard block
 block discarded – undo
583 583
 	 *
584 584
 	 * @return mixed      If successful, the new count, otherwise false.
585 585
 	 */
586
-	public function decrease_purchase_count( $count = 1 ) {
586
+	public function decrease_purchase_count($count = 1) {
587 587
 
588 588
 		// Make sure it's numeric and not negative
589
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
589
+		if ( ! is_numeric($count) || $count != absint($count)) {
590 590
 			return false;
591 591
 		}
592 592
 
593 593
 		$new_total = (int) $this->purchase_count - (int) $count;
594 594
 
595
-		if ( $new_total < 0 ) {
595
+		if ($new_total < 0) {
596 596
 			$new_total = 0;
597 597
 		}
598 598
 
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
 		 * @param int $count       The number to decrease by.
605 605
 		 * @param int $customer_id Customer id.
606 606
 		 */
607
-		do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id );
607
+		do_action('give_customer_pre_decrease_purchase_count', $count, $this->id);
608 608
 
609
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
609
+		if ($this->update(array('purchase_count' => $new_total))) {
610 610
 			$this->purchase_count = $new_total;
611 611
 		}
612 612
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 		 * @param int $count          The number decreased by.
620 620
 		 * @param int $customer_id    Customer id.
621 621
 		 */
622
-		do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id );
622
+		do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id);
623 623
 
624 624
 		return $this->purchase_count;
625 625
 	}
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 	 *
635 635
 	 * @return mixed        If successful, the new value, otherwise false.
636 636
 	 */
637
-	public function increase_value( $value = 0.00 ) {
637
+	public function increase_value($value = 0.00) {
638 638
 
639
-		$new_value = floatval( $this->purchase_value ) + $value;
639
+		$new_value = floatval($this->purchase_value) + $value;
640 640
 
641 641
 		/**
642 642
 		 * Fires before increasing customer lifetime value.
@@ -646,9 +646,9 @@  discard block
 block discarded – undo
646 646
 		 * @param float $value       The value to increase by.
647 647
 		 * @param int   $customer_id Customer id.
648 648
 		 */
649
-		do_action( 'give_customer_pre_increase_value', $value, $this->id );
649
+		do_action('give_customer_pre_increase_value', $value, $this->id);
650 650
 
651
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
651
+		if ($this->update(array('purchase_value' => $new_value))) {
652 652
 			$this->purchase_value = $new_value;
653 653
 		}
654 654
 
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 		 * @param float $value          The value increased by.
662 662
 		 * @param int   $customer_id    Customer id.
663 663
 		 */
664
-		do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id );
664
+		do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id);
665 665
 
666 666
 		return $this->purchase_value;
667 667
 	}
@@ -676,11 +676,11 @@  discard block
 block discarded – undo
676 676
 	 *
677 677
 	 * @return mixed        If successful, the new value, otherwise false.
678 678
 	 */
679
-	public function decrease_value( $value = 0.00 ) {
679
+	public function decrease_value($value = 0.00) {
680 680
 
681
-		$new_value = floatval( $this->purchase_value ) - $value;
681
+		$new_value = floatval($this->purchase_value) - $value;
682 682
 
683
-		if ( $new_value < 0 ) {
683
+		if ($new_value < 0) {
684 684
 			$new_value = 0.00;
685 685
 		}
686 686
 
@@ -692,9 +692,9 @@  discard block
 block discarded – undo
692 692
 		 * @param float $value       The value to decrease by.
693 693
 		 * @param int   $customer_id Customer id.
694 694
 		 */
695
-		do_action( 'give_customer_pre_decrease_value', $value, $this->id );
695
+		do_action('give_customer_pre_decrease_value', $value, $this->id);
696 696
 
697
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
697
+		if ($this->update(array('purchase_value' => $new_value))) {
698 698
 			$this->purchase_value = $new_value;
699 699
 		}
700 700
 
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 		 * @param float $value          The value decreased by.
708 708
 		 * @param int   $customer_id    Customer id.
709 709
 		 */
710
-		do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id );
710
+		do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id);
711 711
 
712 712
 		return $this->purchase_value;
713 713
 	}
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 	 *
727 727
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
728 728
 	 */
729
-	public function update_donation_value( $curr_amount, $new_amount ) {
729
+	public function update_donation_value($curr_amount, $new_amount) {
730 730
         /**
731 731
          * Payment total difference value can be:
732 732
          *  zero   (in case amount not change)
@@ -736,13 +736,13 @@  discard block
 block discarded – undo
736 736
         $payment_total_diff = $new_amount - $curr_amount;
737 737
 
738 738
         // We do not need to update donation stat if donation did not change.
739
-        if( ! $payment_total_diff ) {
739
+        if ( ! $payment_total_diff) {
740 740
             return false;
741 741
         }
742 742
 
743 743
 
744
-        if( $payment_total_diff > 0 ) {
745
-            $this->increase_value( $payment_total_diff );
744
+        if ($payment_total_diff > 0) {
745
+            $this->increase_value($payment_total_diff);
746 746
         } else {
747 747
             // Pass payment total difference as +ve value to decrease amount from user lifetime stat.
748 748
             $this->decrease_value( -$payment_total_diff );
@@ -762,15 +762,15 @@  discard block
 block discarded – undo
762 762
 	 *
763 763
 	 * @return array       The notes requested.
764 764
 	 */
765
-	public function get_notes( $length = 20, $paged = 1 ) {
765
+	public function get_notes($length = 20, $paged = 1) {
766 766
 
767
-		$length = is_numeric( $length ) ? $length : 20;
768
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
767
+		$length = is_numeric($length) ? $length : 20;
768
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
769 769
 
770 770
 		$all_notes   = $this->get_raw_notes();
771
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
771
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
772 772
 
773
-		$desired_notes = array_slice( $notes_array, $offset, $length );
773
+		$desired_notes = array_slice($notes_array, $offset, $length);
774 774
 
775 775
 		return $desired_notes;
776 776
 
@@ -787,9 +787,9 @@  discard block
 block discarded – undo
787 787
 	public function get_notes_count() {
788 788
 
789 789
 		$all_notes   = $this->get_raw_notes();
790
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
790
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
791 791
 
792
-		return count( $notes_array );
792
+		return count($notes_array);
793 793
 
794 794
 	}
795 795
 
@@ -803,22 +803,22 @@  discard block
 block discarded – undo
803 803
 	 *
804 804
 	 * @return string|boolean The new note if added successfully, false otherwise.
805 805
 	 */
806
-	public function add_note( $note = '' ) {
806
+	public function add_note($note = '') {
807 807
 
808
-		$note = trim( $note );
809
-		if ( empty( $note ) ) {
808
+		$note = trim($note);
809
+		if (empty($note)) {
810 810
 			return false;
811 811
 		}
812 812
 
813 813
 		$notes = $this->get_raw_notes();
814 814
 
815
-		if ( empty( $notes ) ) {
815
+		if (empty($notes)) {
816 816
 			$notes = '';
817 817
 		}
818 818
 
819
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
820
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
821
-		$notes .= "\n\n" . $new_note;
819
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
820
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
821
+		$notes .= "\n\n".$new_note;
822 822
 
823 823
 		/**
824 824
 		 * Fires before customer note added.
@@ -828,11 +828,11 @@  discard block
 block discarded – undo
828 828
 		 * @param string $new_note    New note to add.
829 829
 		 * @param int    $customer_id Customer id.
830 830
 		 */
831
-		do_action( 'give_customer_pre_add_note', $new_note, $this->id );
831
+		do_action('give_customer_pre_add_note', $new_note, $this->id);
832 832
 
833
-		$updated = $this->update( array( 'notes' => $notes ) );
833
+		$updated = $this->update(array('notes' => $notes));
834 834
 
835
-		if ( $updated ) {
835
+		if ($updated) {
836 836
 			$this->notes = $this->get_notes();
837 837
 		}
838 838
 
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
 		 * @param string $new_note       New note added.
846 846
 		 * @param int    $customer_id    Customer id.
847 847
 		 */
848
-		do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id );
848
+		do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id);
849 849
 
850 850
 		// Return the formatted note, so we can test, as well as update any displays
851 851
 		return $new_note;
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 	 */
863 863
 	private function get_raw_notes() {
864 864
 
865
-		$all_notes = $this->db->get_column( 'notes', $this->id );
865
+		$all_notes = $this->db->get_column('notes', $this->id);
866 866
 
867 867
 		return $all_notes;
868 868
 
@@ -879,8 +879,8 @@  discard block
 block discarded – undo
879 879
 	 *
880 880
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
881 881
 	 */
882
-	public function get_meta( $meta_key = '', $single = true ) {
883
-		return Give()->customer_meta->get_meta( $this->id, $meta_key, $single );
882
+	public function get_meta($meta_key = '', $single = true) {
883
+		return Give()->customer_meta->get_meta($this->id, $meta_key, $single);
884 884
 	}
885 885
 
886 886
 	/**
@@ -895,8 +895,8 @@  discard block
 block discarded – undo
895 895
 	 *
896 896
 	 * @return bool               False for failure. True for success.
897 897
 	 */
898
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
899
-		return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
898
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
899
+		return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
900 900
 	}
901 901
 
902 902
 	/**
@@ -911,8 +911,8 @@  discard block
 block discarded – undo
911 911
 	 *
912 912
 	 * @return bool               False on failure, true if success.
913 913
 	 */
914
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
915
-		return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
914
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
915
+		return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
916 916
 	}
917 917
 
918 918
 	/**
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 	 *
927 927
 	 * @return bool               False for failure. True for success.
928 928
 	 */
929
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
930
-		return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value );
929
+	public function delete_meta($meta_key = '', $meta_value = '') {
930
+		return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value);
931 931
 	}
932 932
 
933 933
 	/**
@@ -940,51 +940,51 @@  discard block
 block discarded – undo
940 940
 	 *
941 941
 	 * @return array       The sanitized data, based off column defaults.
942 942
 	 */
943
-	private function sanitize_columns( $data ) {
943
+	private function sanitize_columns($data) {
944 944
 
945 945
 		$columns        = $this->db->get_columns();
946 946
 		$default_values = $this->db->get_column_defaults();
947 947
 
948
-		foreach ( $columns as $key => $type ) {
948
+		foreach ($columns as $key => $type) {
949 949
 
950 950
 			// Only sanitize data that we were provided
951
-			if ( ! array_key_exists( $key, $data ) ) {
951
+			if ( ! array_key_exists($key, $data)) {
952 952
 				continue;
953 953
 			}
954 954
 
955
-			switch ( $type ) {
955
+			switch ($type) {
956 956
 
957 957
 				case '%s':
958
-					if ( 'email' == $key ) {
959
-						$data[ $key ] = sanitize_email( $data[ $key ] );
960
-					} elseif ( 'notes' == $key ) {
961
-						$data[ $key ] = strip_tags( $data[ $key ] );
958
+					if ('email' == $key) {
959
+						$data[$key] = sanitize_email($data[$key]);
960
+					} elseif ('notes' == $key) {
961
+						$data[$key] = strip_tags($data[$key]);
962 962
 					} else {
963
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
963
+						$data[$key] = sanitize_text_field($data[$key]);
964 964
 					}
965 965
 					break;
966 966
 
967 967
 				case '%d':
968
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
969
-						$data[ $key ] = $default_values[ $key ];
968
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
969
+						$data[$key] = $default_values[$key];
970 970
 					} else {
971
-						$data[ $key ] = absint( $data[ $key ] );
971
+						$data[$key] = absint($data[$key]);
972 972
 					}
973 973
 					break;
974 974
 
975 975
 				case '%f':
976 976
 					// Convert what was given to a float
977
-					$value = floatval( $data[ $key ] );
977
+					$value = floatval($data[$key]);
978 978
 
979
-					if ( ! is_float( $value ) ) {
980
-						$data[ $key ] = $default_values[ $key ];
979
+					if ( ! is_float($value)) {
980
+						$data[$key] = $default_values[$key];
981 981
 					} else {
982
-						$data[ $key ] = $value;
982
+						$data[$key] = $value;
983 983
 					}
984 984
 					break;
985 985
 
986 986
 				default:
987
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
987
+					$data[$key] = sanitize_text_field($data[$key]);
988 988
 					break;
989 989
 
990 990
 			}
@@ -1002,33 +1002,33 @@  discard block
 block discarded – undo
1002 1002
 	 * @param  bool   $primary Allows setting the email added as the primary
1003 1003
 	 * @return bool            If the email was added successfully
1004 1004
 	 */
1005
-	public function add_email( $email = '', $primary = false ) {
1006
-		if( ! is_email( $email ) ) {
1005
+	public function add_email($email = '', $primary = false) {
1006
+		if ( ! is_email($email)) {
1007 1007
 			return false;
1008 1008
 		}
1009
-		$existing = new Give_Customer( $email );
1009
+		$existing = new Give_Customer($email);
1010 1010
 
1011
-		if( $existing->id > 0 ) {
1011
+		if ($existing->id > 0) {
1012 1012
 			// Email address already belongs to another customer
1013 1013
 			return false;
1014 1014
 		}
1015 1015
 
1016
-		if ( email_exists( $email ) ) {
1017
-			$user = get_user_by( 'email', $email );
1018
-			if ( $user->ID != $this->user_id ) {
1016
+		if (email_exists($email)) {
1017
+			$user = get_user_by('email', $email);
1018
+			if ($user->ID != $this->user_id) {
1019 1019
 				return false;
1020 1020
 			}
1021 1021
 		}
1022 1022
 
1023
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1023
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1024 1024
 
1025 1025
 		// Add is used to ensure duplicate emails are not added
1026
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1026
+		$ret = (bool) $this->add_meta('additional_email', $email);
1027 1027
 
1028
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1028
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1029 1029
 
1030
-		if ( $ret && true === $primary ) {
1031
-			$this->set_primary_email( $email );
1030
+		if ($ret && true === $primary) {
1031
+			$this->set_primary_email($email);
1032 1032
 		}
1033 1033
 
1034 1034
 		return $ret;
@@ -1042,16 +1042,16 @@  discard block
 block discarded – undo
1042 1042
 	 * @param  string $email The email address to remove from the customer
1043 1043
 	 * @return bool          If the email was removeed successfully
1044 1044
 	 */
1045
-	public function remove_email( $email = '' ) {
1046
-		if( ! is_email( $email ) ) {
1045
+	public function remove_email($email = '') {
1046
+		if ( ! is_email($email)) {
1047 1047
 			return false;
1048 1048
 		}
1049 1049
 
1050
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1050
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1051 1051
 
1052
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1052
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1053 1053
 
1054
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1054
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1055 1055
 
1056 1056
 		return $ret;
1057 1057
 	}
@@ -1065,16 +1065,16 @@  discard block
 block discarded – undo
1065 1065
 	 * @param  string $new_primary_email The email address to remove from the customer
1066 1066
 	 * @return bool                      If the email was set as primary successfully
1067 1067
 	 */
1068
-	public function set_primary_email( $new_primary_email = '' ) {
1069
-		if( ! is_email( $new_primary_email ) ) {
1068
+	public function set_primary_email($new_primary_email = '') {
1069
+		if ( ! is_email($new_primary_email)) {
1070 1070
 			return false;
1071 1071
 		}
1072 1072
 
1073
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1073
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1074 1074
 
1075
-		$existing = new Give_Customer( $new_primary_email );
1075
+		$existing = new Give_Customer($new_primary_email);
1076 1076
 
1077
-		if( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1077
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1078 1078
 			// This email belongs to another customer
1079 1079
 			return false;
1080 1080
 		}
@@ -1082,21 +1082,21 @@  discard block
 block discarded – undo
1082 1082
 		$old_email = $this->email;
1083 1083
 
1084 1084
 		// Update customer record with new email
1085
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1085
+		$update = $this->update(array('email' => $new_primary_email));
1086 1086
 
1087 1087
 		// Remove new primary from list of additional emails
1088
-		$remove = $this->remove_email( $new_primary_email );
1088
+		$remove = $this->remove_email($new_primary_email);
1089 1089
 
1090 1090
 		// Add old email to additional emails list
1091
-		$add = $this->add_email( $old_email );
1091
+		$add = $this->add_email($old_email);
1092 1092
 
1093 1093
 		$ret = $update && $remove && $add;
1094 1094
 
1095
-		if( $ret ) {
1095
+		if ($ret) {
1096 1096
 			$this->email = $new_primary_email;
1097 1097
 		}
1098 1098
 
1099
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1099
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1100 1100
 
1101 1101
 		return $ret;
1102 1102
 	}
Please login to merge, or discard this patch.
includes/api/class-give-api-v1.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 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
 
Please login to merge, or discard this patch.
includes/forms/widget.php 1 patch
Spacing   +49 added lines, -49 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
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  *
20 20
  * @since 1.0
21 21
  */
22
-class Give_Forms_Widget extends WP_Widget{
22
+class Give_Forms_Widget extends WP_Widget {
23 23
 	/**
24 24
 	 * The widget class name
25 25
 	 *
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * Instantiate the class
32 32
 	 */
33
-	public function __construct(){
34
-		$this->self = get_class( $this );
33
+	public function __construct() {
34
+		$this->self = get_class($this);
35 35
 
36 36
 		parent::__construct(
37
-			strtolower( $this->self ),
38
-			esc_html__( 'Give - Donation Form', 'give' ),
37
+			strtolower($this->self),
38
+			esc_html__('Give - Donation Form', 'give'),
39 39
 			array(
40
-				'description' => esc_html__( 'Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give' )
40
+				'description' => esc_html__('Display a Give Donation Form in your theme\'s widget powered sidebar.', 'give')
41 41
 			)
42 42
 		);
43 43
 
44
-		add_action( 'widgets_init',          array( $this, 'widget_init' ) );
45
-		add_action( 'admin_enqueue_scripts', array( $this, 'admin_widget_scripts' ) );
44
+		add_action('widgets_init', array($this, 'widget_init'));
45
+		add_action('admin_enqueue_scripts', array($this, 'admin_widget_scripts'));
46 46
 	}
47 47
 
48 48
 	/**
@@ -52,23 +52,23 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return void
54 54
 	 */
55
-	public function admin_widget_scripts( $hook ){
55
+	public function admin_widget_scripts($hook) {
56 56
 		// Directories of assets
57
-		$js_dir     = GIVE_PLUGIN_URL . 'assets/js/admin/';
58
-		$js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/';
59
-		$css_dir    = GIVE_PLUGIN_URL . 'assets/css/';
57
+		$js_dir     = GIVE_PLUGIN_URL.'assets/js/admin/';
58
+		$js_plugins = GIVE_PLUGIN_URL.'assets/js/plugins/';
59
+		$css_dir    = GIVE_PLUGIN_URL.'assets/css/';
60 60
 
61 61
 		// Use minified libraries if SCRIPT_DEBUG is turned off
62
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
62
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
63 63
 
64 64
 		// Widget Script
65
-		if ( $hook == 'widgets.php' ) {
65
+		if ($hook == 'widgets.php') {
66 66
 
67
-			wp_enqueue_style( 'give-qtip-css', $css_dir . 'jquery.qtip' . $suffix . '.css' );
67
+			wp_enqueue_style('give-qtip-css', $css_dir.'jquery.qtip'.$suffix.'.css');
68 68
 
69
-			wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
69
+			wp_enqueue_script('give-qtip', $js_plugins.'jquery.qtip'.$suffix.'.js', array('jquery'), GIVE_VERSION);
70 70
 
71
-			wp_enqueue_script( 'give-admin-widgets-scripts', $js_dir . 'admin-widgets' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION, false );
71
+			wp_enqueue_script('give-admin-widgets-scripts', $js_dir.'admin-widgets'.$suffix.'.js', array('jquery'), GIVE_VERSION, false);
72 72
 		}
73 73
 	}
74 74
 
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	 *                        before_widget, and after_widget.
80 80
 	 * @param array $instance The settings for the particular instance of the widget.
81 81
 	 */
82
-	public function widget( $args, $instance ){
83
-		$title = !empty( $instance['title'] ) ? $instance['title'] : '';
84
-		$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
82
+	public function widget($args, $instance) {
83
+		$title = ! empty($instance['title']) ? $instance['title'] : '';
84
+		$title = apply_filters('widget_title', $title, $instance, $this->id_base);
85 85
 
86 86
 		echo $args['before_widget'];
87 87
 
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 		 *
91 91
 		 * @since 1.0
92 92
 		 */
93
-		do_action( 'give_before_forms_widget' );
93
+		do_action('give_before_forms_widget');
94 94
 
95
-		echo $title ? $args['before_title'] . $title . $args['after_title'] : '';
95
+		echo $title ? $args['before_title'].$title.$args['after_title'] : '';
96 96
 
97
-		give_get_donation_form( $instance );
97
+		give_get_donation_form($instance);
98 98
 
99 99
 		echo $args['after_widget'];
100 100
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		 *
104 104
 		 * @since 1.0
105 105
 		 */
106
-		do_action( 'give_after_forms_widget' );
106
+		do_action('give_after_forms_widget');
107 107
 	}
108 108
 
109 109
 	/**
@@ -113,55 +113,55 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @return string
115 115
 	 */
116
-	public function form( $instance ){
116
+	public function form($instance) {
117 117
 		$defaults = array(
118 118
 			'title'        => '',
119 119
 			'id'           => '',
120 120
 			'float_labels' => '',
121 121
 		);
122 122
 
123
-		$instance = wp_parse_args( (array) $instance, $defaults );
123
+		$instance = wp_parse_args((array) $instance, $defaults);
124 124
 
125 125
 		// Query Give Forms
126 126
 		$args = array(
127 127
 			'post_type'      => 'give_forms',
128
-			'posts_per_page' => - 1,
128
+			'posts_per_page' => -1,
129 129
 			'post_status'    => 'publish',
130 130
 		);
131 131
 
132
-		$give_forms = get_posts( $args );
132
+		$give_forms = get_posts($args);
133 133
 
134 134
 		// Widget: Title
135 135
 
136 136
 		?><p>
137
-			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ); ?></label>
138
-			<input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" /><br>
139
-			<small><?php esc_html_e( 'Leave blank to hide the widget title.', 'give' ); ?></small>
137
+			<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give'); ?></label>
138
+			<input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title']); ?>" /><br>
139
+			<small><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?></small>
140 140
 		</p><?php
141 141
 
142 142
 		// Widget: Give Form
143 143
 
144 144
 		?><p>
145
-			<label for="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>"><?php esc_html_e( 'Give Form:', 'give' ); ?></label>
146
-			<select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'id' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'id' ) ); ?>">
147
-				<option value="current"><?php esc_html_e( '- Select -', 'give' ); ?></option>
148
-				<?php foreach ( $give_forms as $give_form ) { ?>
149
-					<option <?php selected( absint( $instance['id'] ), $give_form->ID ); ?> value="<?php echo esc_attr( $give_form->ID ); ?>"><?php echo $give_form->post_title; ?></option>
145
+			<label for="<?php echo esc_attr($this->get_field_id('id')); ?>"><?php esc_html_e('Give Form:', 'give'); ?></label>
146
+			<select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?>" id="<?php echo esc_attr($this->get_field_id('id')); ?>">
147
+				<option value="current"><?php esc_html_e('- Select -', 'give'); ?></option>
148
+				<?php foreach ($give_forms as $give_form) { ?>
149
+					<option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?>"><?php echo $give_form->post_title; ?></option>
150 150
 				<?php } ?>
151 151
 			</select><br>
152
-			<small><?php esc_html_e( 'Select a Give Form to embed in this widget.', 'give' ); ?></small>
152
+			<small><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?></small>
153 153
 		</p><?php
154 154
 
155 155
 		// Widget: Floating Labels
156 156
 
157 157
 		?><p>
158
-			<label for="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>"><?php esc_html_e( 'Floating Labels:', 'give' ); ?></label>
159
-			<select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'float_labels' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'float_labels' ) ); ?>">
160
-				<option value="" <?php selected( esc_attr( $instance['float_labels'] ), '' ) ?>><?php esc_html_e( '- Select -', 'give' ); ?></option>
161
-				<option value="enabled" <?php selected( esc_attr( $instance['float_labels'] ), 'enabled' ) ?>><?php esc_html_e( 'Enabled', 'give' ); ?></option>
162
-				<option value="disabled" <?php selected( esc_attr( $instance['float_labels'] ), 'disabled' ) ?>><?php esc_html_e( 'Disabled', 'give' ); ?></option>
158
+			<label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?>"><?php esc_html_e('Floating Labels:', 'give'); ?></label>
159
+			<select class="widefat" name="<?php echo esc_attr($this->get_field_name('float_labels')); ?>" id="<?php echo esc_attr($this->get_field_id('float_labels')); ?>">
160
+				<option value="" <?php selected(esc_attr($instance['float_labels']), '') ?>><?php esc_html_e('- Select -', 'give'); ?></option>
161
+				<option value="enabled" <?php selected(esc_attr($instance['float_labels']), 'enabled') ?>><?php esc_html_e('Enabled', 'give'); ?></option>
162
+				<option value="disabled" <?php selected(esc_attr($instance['float_labels']), 'disabled') ?>><?php esc_html_e('Disabled', 'give'); ?></option>
163 163
 			</select><br>
164
-			<small><?php esc_html_e( 'Override the default floating labels setting for this form.', 'give' ); ?></small>
164
+			<small><?php esc_html_e('Override the default floating labels setting for this form.', 'give'); ?></small>
165 165
 		</p><?php
166 166
 	}
167 167
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @return void
172 172
 	 */
173
-	function widget_init(){
174
-		register_widget( $this->self );
173
+	function widget_init() {
174
+		register_widget($this->self);
175 175
 	}
176 176
 
177 177
 	/**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @return array
184 184
 	 */
185
-	public function update( $new_instance, $old_instance ){
185
+	public function update($new_instance, $old_instance) {
186 186
 		$this->flush_widget_cache();
187 187
 
188 188
 		return $new_instance;
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @return void
195 195
 	 */
196
-	public function flush_widget_cache(){
197
-		wp_cache_delete( $this->self, 'widget' );
196
+	public function flush_widget_cache() {
197
+		wp_cache_delete($this->self, 'widget');
198 198
 	}
199 199
 }
200 200
 
Please login to merge, or discard this patch.