Completed
Pull Request — master (#1619)
by Ravinder
17:48
created
includes/admin/class-give-settings.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @param $url
74 74
 	 *
75
-	 * @return mixed
75
+	 * @return string
76 76
 	 */
77 77
 	public function give_update_cmb_meta_box_url( $url ) {
78 78
 		// Path to Give's CMB
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
  * @since 1.0
835 835
  *
836 836
  * @param string          $key   The Key to update
837
- * @param string|bool|int $value The value to set the key to
837
+ * @param integer $value The value to set the key to
838 838
  *
839 839
  * @return boolean True if updated, false if not.
840 840
  */
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
  * @since      1.3.5
938 938
  *
939 939
  * @param $array
940
- * @param $position |int|string Expects an array key or 'id' of the settings field to appear after
940
+ * @param string $position |int|string Expects an array key or 'id' of the settings field to appear after
941 941
  * @param $insert   |array a valid array of options to insert
942 942
  *
943 943
  * @return array
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
  * @since 1.0
977 977
  *
978 978
  * @param array $field_arr
979
- * @param array $saved_values
979
+ * @param string|boolean $saved_values
980 980
  *
981 981
  * @return void
982 982
  */
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
  * @since  1.0
1012 1012
  *
1013 1013
  * @param  array $field_arr
1014
- * @param  array $saved_value
1014
+ * @param  string|boolean $saved_value
1015 1015
  *
1016 1016
  * @return void
1017 1017
  */
Please login to merge, or discard this patch.
Spacing   +362 added lines, -362 removed lines patch added patch discarded remove patch
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
 	public function __construct() {
44 44
 
45 45
 		// Custom CMB2 Settings Fields
46
-		add_action( 'cmb2_render_give_title', 'give_title_callback', 10, 5 );
47
-		add_action( 'cmb2_render_give_description', 'give_description_callback', 10, 5 );
48
-		add_action( 'cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5 );
49
-		add_action( 'cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5 );
50
-		add_action( 'cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5 );
51
-		add_action( 'cmb2_render_system_info', 'give_system_info_callback', 10, 5 );
52
-		add_action( 'cmb2_render_api', 'give_api_callback', 10, 5 );
53
-		add_action( 'cmb2_render_license_key', 'give_license_key_callback', 10, 5 );
46
+		add_action('cmb2_render_give_title', 'give_title_callback', 10, 5);
47
+		add_action('cmb2_render_give_description', 'give_description_callback', 10, 5);
48
+		add_action('cmb2_render_enabled_gateways', 'give_enabled_gateways_callback', 10, 5);
49
+		add_action('cmb2_render_default_gateway', 'give_default_gateway_callback', 10, 5);
50
+		add_action('cmb2_render_email_preview_buttons', 'give_email_preview_buttons_callback', 10, 5);
51
+		add_action('cmb2_render_system_info', 'give_system_info_callback', 10, 5);
52
+		add_action('cmb2_render_api', 'give_api_callback', 10, 5);
53
+		add_action('cmb2_render_license_key', 'give_license_key_callback', 10, 5);
54 54
 	}
55 55
 
56 56
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @since  1.0
61 61
 	 */
62 62
 	public function init() {
63
-		register_setting( $this->key, $this->key );
63
+		register_setting($this->key, $this->key);
64 64
 
65 65
 	}
66 66
 
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return mixed
76 76
 	 */
77
-	public function give_update_cmb_meta_box_url( $url ) {
77
+	public function give_update_cmb_meta_box_url($url) {
78 78
 		// Path to Give's CMB
79
-		return GIVE_PLUGIN_URL . '/includes/libraries/cmb2';
79
+		return GIVE_PLUGIN_URL.'/includes/libraries/cmb2';
80 80
 	}
81 81
 
82 82
 
@@ -88,27 +88,27 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	public function give_get_settings_tabs() {
90 90
 
91
-		$settings = $this->give_settings( null );
91
+		$settings = $this->give_settings(null);
92 92
 
93 93
 		$tabs             = array();
94
-		$tabs['general']  = esc_html__( 'General', 'give' );
95
-		$tabs['gateways'] = esc_html__( 'Payment Gateways', 'give' );
96
-		$tabs['display']  = esc_html__( 'Display Options', 'give' );
97
-		$tabs['emails']   = esc_html__( 'Emails', 'give' );
94
+		$tabs['general']  = esc_html__('General', 'give');
95
+		$tabs['gateways'] = esc_html__('Payment Gateways', 'give');
96
+		$tabs['display']  = esc_html__('Display Options', 'give');
97
+		$tabs['emails']   = esc_html__('Emails', 'give');
98 98
 
99
-		if ( ! empty( $settings['addons']['fields'] ) ) {
100
-			$tabs['addons'] = esc_html__( 'Add-ons', 'give' );
99
+		if ( ! empty($settings['addons']['fields'])) {
100
+			$tabs['addons'] = esc_html__('Add-ons', 'give');
101 101
 		}
102 102
 
103
-		if ( ! empty( $settings['licenses']['fields'] ) ) {
104
-			$tabs['licenses'] = esc_html__( 'Licenses', 'give' );
103
+		if ( ! empty($settings['licenses']['fields'])) {
104
+			$tabs['licenses'] = esc_html__('Licenses', 'give');
105 105
 		}
106 106
 
107
-		$tabs['advanced']    = esc_html__( 'Advanced', 'give' );
108
-		$tabs['api']         = esc_html__( 'API', 'give' );
109
-		$tabs['system_info'] = esc_html__( 'System Info', 'give' );
107
+		$tabs['advanced']    = esc_html__('Advanced', 'give');
108
+		$tabs['api']         = esc_html__('API', 'give');
109
+		$tabs['system_info'] = esc_html__('System Info', 'give');
110 110
 
111
-		return apply_filters( 'give_settings_tabs', $tabs );
111
+		return apply_filters('give_settings_tabs', $tabs);
112 112
 	}
113 113
 
114 114
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 */
120 120
 	public function admin_page_display() {
121 121
 
122
-		$active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->give_get_settings_tabs() ) ? $_GET['tab'] : 'general';
122
+		$active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $this->give_get_settings_tabs()) ? $_GET['tab'] : 'general';
123 123
 
124 124
 		?>
125 125
 
@@ -129,22 +129,22 @@  discard block
 block discarded – undo
129 129
 
130 130
 			<h2 class="nav-tab-wrapper">
131 131
 				<?php
132
-				foreach ( $this->give_get_settings_tabs() as $tab_id => $tab_name ) {
132
+				foreach ($this->give_get_settings_tabs() as $tab_id => $tab_name) {
133 133
 
134
-					$tab_url = esc_url( add_query_arg( array(
134
+					$tab_url = esc_url(add_query_arg(array(
135 135
 						'settings-updated' => false,
136 136
 						'tab'              => $tab_id,
137
-					) ) );
137
+					)));
138 138
 
139 139
 					$active = $active_tab == $tab_id ? ' nav-tab-active' : '';
140 140
 
141
-					echo '<a href="' . esc_url( $tab_url ) . '" class="nav-tab' . $active . '" id="tab-' . $tab_id . '">' . esc_html( $tab_name ) . '</a>';
141
+					echo '<a href="'.esc_url($tab_url).'" class="nav-tab'.$active.'" id="tab-'.$tab_id.'">'.esc_html($tab_name).'</a>';
142 142
 
143 143
 				}
144 144
 				?>
145 145
 			</h2>
146 146
 
147
-			<?php cmb2_metabox_form( $this->give_settings( $active_tab ), $this->key ); ?>
147
+			<?php cmb2_metabox_form($this->give_settings($active_tab), $this->key); ?>
148 148
 
149 149
 		</div><!-- .wrap -->
150 150
 
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @return string
168 168
 	 */
169
-	function give_modify_cmb2_form_output( $form_format, $object_id, $cmb ) {
169
+	function give_modify_cmb2_form_output($form_format, $object_id, $cmb) {
170 170
 
171 171
 		// only modify the give settings form
172
-		if ( 'give_settings' == $object_id ) {
172
+		if ('give_settings' == $object_id) {
173 173
 
174
-			return '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="' . esc_attr__( 'Save Settings', 'give' ) . '" class="button-primary"></div></form>';
174
+			return '<form class="cmb-form" method="post" id="%1$s" enctype="multipart/form-data" encoding="multipart/form-data"><input type="hidden" name="give_settings_saved" value="true"><input type="hidden" name="object_id" value="%2$s">%3$s<div class="give-submit-wrap"><input type="submit" name="submit-cmb" value="'.esc_attr__('Save Settings', 'give').'" class="button-primary"></div></form>';
175 175
 
176 176
 		}
177 177
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return array
190 190
 	 */
191
-	public function give_settings( $active_tab ) {
191
+	public function give_settings($active_tab) {
192 192
 
193 193
 		$give_settings = array(
194 194
 			/**
@@ -196,99 +196,99 @@  discard block
 block discarded – undo
196 196
 			 */
197 197
 			'general'     => array(
198 198
 				'id'         => 'general_settings',
199
-				'give_title' => esc_html__( 'General Settings', 'give' ),
200
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
201
-				'fields'     => apply_filters( 'give_settings_general', array(
199
+				'give_title' => esc_html__('General Settings', 'give'),
200
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
201
+				'fields'     => apply_filters('give_settings_general', array(
202 202
 						array(
203
-							'name' => esc_html__( 'General Settings', 'give' ),
203
+							'name' => esc_html__('General Settings', 'give'),
204 204
 							'desc' => '',
205 205
 							'type' => 'give_title',
206 206
 							'id'   => 'give_title_general_settings_1',
207 207
 						),
208 208
 						array(
209
-							'name'    => esc_html__( 'Success Page', 'give' ),
209
+							'name'    => esc_html__('Success Page', 'give'),
210 210
 							/* translators: %s: [give_receipt] */
211
-							'desc'    => sprintf( __( 'The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give' ), '<code>[give_receipt]</code>' ),
211
+							'desc'    => sprintf(__('The page donors are sent to after completing their donations. The %s shortcode should be on this page.', 'give'), '<code>[give_receipt]</code>'),
212 212
 							'id'      => 'success_page',
213 213
 							'type'    => 'select',
214
-							'options' => give_cmb2_get_post_options( array(
214
+							'options' => give_cmb2_get_post_options(array(
215 215
 								'post_type'   => 'page',
216
-								'numberposts' => - 1,
217
-							) ),
216
+								'numberposts' => -1,
217
+							)),
218 218
 						),
219 219
 						array(
220
-							'name'    => esc_html__( 'Failed Donation Page', 'give' ),
221
-							'desc'    => esc_html__( 'The page donors are sent to if their donation is cancelled or fails.', 'give' ),
220
+							'name'    => esc_html__('Failed Donation Page', 'give'),
221
+							'desc'    => esc_html__('The page donors are sent to if their donation is cancelled or fails.', 'give'),
222 222
 							'id'      => 'failure_page',
223 223
 							'type'    => 'select',
224
-							'options' => give_cmb2_get_post_options( array(
224
+							'options' => give_cmb2_get_post_options(array(
225 225
 								'post_type'   => 'page',
226
-								'numberposts' => - 1,
227
-							) ),
226
+								'numberposts' => -1,
227
+							)),
228 228
 						),
229 229
 						array(
230
-							'name'    => esc_html__( 'Donation History Page', 'give' ),
230
+							'name'    => esc_html__('Donation History Page', 'give'),
231 231
 							/* translators: %s: [donation_history] */
232
-							'desc'    => sprintf( __( 'The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give' ), '<code>[donation_history]</code>' ),
232
+							'desc'    => sprintf(__('The page showing a complete donation history for the current user. The %s shortcode should be on this page.', 'give'), '<code>[donation_history]</code>'),
233 233
 							'id'      => 'history_page',
234 234
 							'type'    => 'select',
235
-							'options' => give_cmb2_get_post_options( array(
235
+							'options' => give_cmb2_get_post_options(array(
236 236
 								'post_type'   => 'page',
237
-								'numberposts' => - 1,
238
-							) ),
237
+								'numberposts' => -1,
238
+							)),
239 239
 						),
240 240
 						array(
241
-							'name'    => esc_html__( 'Base Country', 'give' ),
242
-							'desc'    => esc_html__( 'The country your site operates from.', 'give' ),
241
+							'name'    => esc_html__('Base Country', 'give'),
242
+							'desc'    => esc_html__('The country your site operates from.', 'give'),
243 243
 							'id'      => 'base_country',
244 244
 							'type'    => 'select',
245 245
 							'options' => give_get_country_list(),
246 246
 						),
247 247
 						array(
248
-							'name' => esc_html__( 'Currency Settings', 'give' ),
248
+							'name' => esc_html__('Currency Settings', 'give'),
249 249
 							'desc' => '',
250 250
 							'type' => 'give_title',
251 251
 							'id'   => 'give_title_general_settings_2',
252 252
 						),
253 253
 						array(
254
-							'name'    => esc_html__( 'Currency', 'give' ),
255
-							'desc'    => esc_html__( 'The donation currency. Note that some payment gateways have currency restrictions.', 'give' ),
254
+							'name'    => esc_html__('Currency', 'give'),
255
+							'desc'    => esc_html__('The donation currency. Note that some payment gateways have currency restrictions.', 'give'),
256 256
 							'id'      => 'currency',
257 257
 							'type'    => 'select',
258 258
 							'options' => give_get_currencies(),
259 259
 							'default' => 'USD',
260 260
 						),
261 261
 						array(
262
-							'name'    => esc_html__( 'Currency Position', 'give' ),
263
-							'desc'    => esc_html__( 'The position of the currency symbol.', 'give' ),
262
+							'name'    => esc_html__('Currency Position', 'give'),
263
+							'desc'    => esc_html__('The position of the currency symbol.', 'give'),
264 264
 							'id'      => 'currency_position',
265 265
 							'type'    => 'select',
266 266
 							'options' => array(
267 267
 								/* translators: %s: currency symbol */
268
-								'before' => sprintf( esc_html__( 'Before - %s10', 'give' ), give_currency_symbol( give_get_currency() ) ),
268
+								'before' => sprintf(esc_html__('Before - %s10', 'give'), give_currency_symbol(give_get_currency())),
269 269
 								/* translators: %s: currency symbol */
270
-								'after'  => sprintf( esc_html__( 'After - 10%s', 'give' ), give_currency_symbol( give_get_currency() ) ),
270
+								'after'  => sprintf(esc_html__('After - 10%s', 'give'), give_currency_symbol(give_get_currency())),
271 271
 							),
272 272
 							'default' => 'before',
273 273
 						),
274 274
 						array(
275
-							'name'            => esc_html__( 'Thousands Separator', 'give' ),
276
-							'desc'            => esc_html__( 'The symbol (usually , or .) to separate thousands.', 'give' ),
275
+							'name'            => esc_html__('Thousands Separator', 'give'),
276
+							'desc'            => esc_html__('The symbol (usually , or .) to separate thousands.', 'give'),
277 277
 							'id'              => 'thousands_separator',
278 278
 							'type'            => 'text_small',
279 279
 							'sanitization_cb' => 'give_sanitize_thousand_separator',
280 280
 							'default'         => ',',
281 281
 						),
282 282
 						array(
283
-							'name'    => esc_html__( 'Decimal Separator', 'give' ),
284
-							'desc'    => esc_html__( 'The symbol (usually , or .) to separate decimal points.', 'give' ),
283
+							'name'    => esc_html__('Decimal Separator', 'give'),
284
+							'desc'    => esc_html__('The symbol (usually , or .) to separate decimal points.', 'give'),
285 285
 							'id'      => 'decimal_separator',
286 286
 							'type'    => 'text_small',
287 287
 							'default' => '.',
288 288
 						),
289 289
 						array(
290
-							'name'            => esc_html__( 'Number of Decimals', 'give' ),
291
-							'desc'            => esc_html__( 'The number of decimal points displayed in amounts.', 'give' ),
290
+							'name'            => esc_html__('Number of Decimals', 'give'),
291
+							'desc'            => esc_html__('The number of decimal points displayed in amounts.', 'give'),
292 292
 							'id'              => 'number_decimals',
293 293
 							'type'            => 'text_small',
294 294
 							'default'         => 2,
@@ -302,83 +302,83 @@  discard block
 block discarded – undo
302 302
 			 */
303 303
 			'gateways'    => array(
304 304
 				'id'         => 'payment_gateways',
305
-				'give_title' => esc_html__( 'Payment Gateways', 'give' ),
306
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
307
-				'fields'     => apply_filters( 'give_settings_gateways', array(
305
+				'give_title' => esc_html__('Payment Gateways', 'give'),
306
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
307
+				'fields'     => apply_filters('give_settings_gateways', array(
308 308
 						array(
309
-							'name' => esc_html__( 'Gateways Settings', 'give' ),
309
+							'name' => esc_html__('Gateways Settings', 'give'),
310 310
 							'desc' => '',
311 311
 							'id'   => 'give_title_gateway_settings_1',
312 312
 							'type' => 'give_title',
313 313
 						),
314 314
 						array(
315
-							'name' => esc_html__( 'Test Mode', 'give' ),
316
-							'desc' => esc_html__( 'While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give' ),
315
+							'name' => esc_html__('Test Mode', 'give'),
316
+							'desc' => esc_html__('While in test mode no live donations are processed. To fully use test mode, you must have a sandbox (test) account for the payment gateway you are testing.', 'give'),
317 317
 							'id'   => 'test_mode',
318 318
 							'type' => 'checkbox',
319 319
 						),
320 320
 						array(
321
-							'name' => esc_html__( 'Enabled Gateways', 'give' ),
322
-							'desc' => esc_html__( 'Enable your payment gateway. Can be ordered by dragging.', 'give' ),
321
+							'name' => esc_html__('Enabled Gateways', 'give'),
322
+							'desc' => esc_html__('Enable your payment gateway. Can be ordered by dragging.', 'give'),
323 323
 							'id'   => 'gateways',
324 324
 							'type' => 'enabled_gateways',
325 325
 						),
326 326
 						array(
327
-							'name' => esc_html__( 'Default Gateway', 'give' ),
328
-							'desc' => esc_html__( 'The gateway that will be selected by default.', 'give' ),
327
+							'name' => esc_html__('Default Gateway', 'give'),
328
+							'desc' => esc_html__('The gateway that will be selected by default.', 'give'),
329 329
 							'id'   => 'default_gateway',
330 330
 							'type' => 'default_gateway',
331 331
 						),
332 332
 						array(
333
-							'name' => esc_html__( 'PayPal Standard', 'give' ),
333
+							'name' => esc_html__('PayPal Standard', 'give'),
334 334
 							'desc' => '',
335 335
 							'type' => 'give_title',
336 336
 							'id'   => 'give_title_gateway_settings_2',
337 337
 						),
338 338
 						array(
339
-							'name' => esc_html__( 'PayPal Email', 'give' ),
340
-							'desc' => esc_html__( 'Enter your PayPal account\'s email.', 'give' ),
339
+							'name' => esc_html__('PayPal Email', 'give'),
340
+							'desc' => esc_html__('Enter your PayPal account\'s email.', 'give'),
341 341
 							'id'   => 'paypal_email',
342 342
 							'type' => 'text_email',
343 343
 						),
344 344
 						array(
345
-							'name' => esc_html__( 'PayPal Page Style', 'give' ),
346
-							'desc' => esc_html__( 'Enter the name of the page style to use, or leave blank to use the default.', 'give' ),
345
+							'name' => esc_html__('PayPal Page Style', 'give'),
346
+							'desc' => esc_html__('Enter the name of the page style to use, or leave blank to use the default.', 'give'),
347 347
 							'id'   => 'paypal_page_style',
348 348
 							'type' => 'text',
349 349
 						),
350 350
 						array(
351
-							'name'    => esc_html__( 'PayPal Transaction Type', 'give' ),
352
-							'desc'    => esc_html__( 'Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give' ),
351
+							'name'    => esc_html__('PayPal Transaction Type', 'give'),
352
+							'desc'    => esc_html__('Nonprofits must verify their status to withdraw donations they receive via PayPal. PayPal users that are not verified nonprofits must demonstrate how their donations will be used, once they raise more than $10,000. By default, Give transactions are sent to PayPal as donations. You may change the transaction type using this option if you feel you may not meet PayPal\'s donation requirements.', 'give'),
353 353
 							'id'      => 'paypal_button_type',
354 354
 							'type'    => 'radio_inline',
355 355
 							'options' => array(
356
-								'donation' => esc_html__( 'Donation', 'give' ),
357
-								'standard' => esc_html__( 'Standard Transaction', 'give' ),
356
+								'donation' => esc_html__('Donation', 'give'),
357
+								'standard' => esc_html__('Standard Transaction', 'give'),
358 358
 							),
359 359
 							'default' => 'donation',
360 360
 						),
361 361
 						array(
362
-							'name' => esc_html__( 'Disable PayPal IPN Verification', 'give' ),
363
-							'desc' => esc_html__( 'If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give' ),
362
+							'name' => esc_html__('Disable PayPal IPN Verification', 'give'),
363
+							'desc' => esc_html__('If donations are not getting marked as complete, use a slightly less secure method of verifying donations.', 'give'),
364 364
 							'id'   => 'disable_paypal_verification',
365 365
 							'type' => 'checkbox',
366 366
 						),
367 367
 						array(
368
-							'name' => esc_html__( 'Offline Donations', 'give' ),
368
+							'name' => esc_html__('Offline Donations', 'give'),
369 369
 							'desc' => '',
370 370
 							'type' => 'give_title',
371 371
 							'id'   => 'give_title_gateway_settings_3',
372 372
 						),
373 373
 						array(
374
-							'name' => esc_html__( 'Collect Billing Details', 'give' ),
375
-							'desc' => esc_html__( 'Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give' ),
374
+							'name' => esc_html__('Collect Billing Details', 'give'),
375
+							'desc' => esc_html__('Enable to request billing details for offline donations. Will appear above offline donation instructions. Can be enabled/disabled per form.', 'give'),
376 376
 							'id'   => 'give_offline_donation_enable_billing_fields',
377 377
 							'type' => 'checkbox',
378 378
 						),
379 379
 						array(
380
-							'name'    => esc_html__( 'Offline Donation Instructions', 'give' ),
381
-							'desc'    => esc_html__( 'The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give' ),
380
+							'name'    => esc_html__('Offline Donation Instructions', 'give'),
381
+							'desc'    => esc_html__('The following content will appear for all forms when the user selects the offline donation payment option. Note: You may customize the content per form as needed.', 'give'),
382 382
 							'id'      => 'global_offline_donation_content',
383 383
 							'default' => give_get_default_offline_donation_content(),
384 384
 							'type'    => 'wysiwyg',
@@ -387,15 +387,15 @@  discard block
 block discarded – undo
387 387
 							),
388 388
 						),
389 389
 						array(
390
-							'name'    => esc_html__( 'Offline Donation Email Instructions Subject', 'give' ),
391
-							'desc'    => esc_html__( 'Enter the subject line for the donation receipt email.', 'give' ),
390
+							'name'    => esc_html__('Offline Donation Email Instructions Subject', 'give'),
391
+							'desc'    => esc_html__('Enter the subject line for the donation receipt email.', 'give'),
392 392
 							'id'      => 'offline_donation_subject',
393
-							'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ),
393
+							'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'),
394 394
 							'type'    => 'text',
395 395
 						),
396 396
 						array(
397
-							'name'    => esc_html__( 'Offline Donation Email Instructions', 'give' ),
398
-							'desc'    => esc_html__( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ),
397
+							'name'    => esc_html__('Offline Donation Email Instructions', 'give'),
398
+							'desc'    => esc_html__('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'),
399 399
 							'id'      => 'global_offline_donation_email',
400 400
 							'default' => give_get_default_offline_donation_email_content(),
401 401
 							'type'    => 'wysiwyg',
@@ -409,104 +409,104 @@  discard block
 block discarded – undo
409 409
 			/** Display Settings */
410 410
 			'display'     => array(
411 411
 				'id'         => 'display_settings',
412
-				'give_title' => esc_html__( 'Display Settings', 'give' ),
413
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
414
-				'fields'     => apply_filters( 'give_settings_display', array(
412
+				'give_title' => esc_html__('Display Settings', 'give'),
413
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
414
+				'fields'     => apply_filters('give_settings_display', array(
415 415
 						array(
416
-							'name' => esc_html__( 'Display Settings', 'give' ),
416
+							'name' => esc_html__('Display Settings', 'give'),
417 417
 							'desc' => '',
418 418
 							'id'   => 'give_title_display_settings_1',
419 419
 							'type' => 'give_title',
420 420
 						),
421 421
 						array(
422
-							'name' => esc_html__( 'Disable CSS', 'give' ),
423
-							'desc' => esc_html__( 'Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give' ),
422
+							'name' => esc_html__('Disable CSS', 'give'),
423
+							'desc' => esc_html__('Enable this option if you would like to disable all of Give\'s included CSS stylesheets.', 'give'),
424 424
 							'id'   => 'disable_css',
425 425
 							'type' => 'checkbox',
426 426
 						),
427 427
 						array(
428
-							'name' => esc_html__( 'Enable Floating Labels', 'give' ),
428
+							'name' => esc_html__('Enable Floating Labels', 'give'),
429 429
 							/* translators: %s: http://docs.givewp.com/form-floating-labels */
430
-							'desc' => sprintf( wp_kses( __( 'Enable <a href="%s" target="_blank">floating labels</a> in Give\'s donation forms. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give' ), array(
430
+							'desc' => sprintf(wp_kses(__('Enable <a href="%s" target="_blank">floating labels</a> in Give\'s donation forms. Note that if the "Disable CSS" option is enabled, you will need to style the floating labels yourself.', 'give'), array(
431 431
 								'a' => array(
432 432
 									'href'   => array(),
433 433
 									'target' => array(),
434 434
 								),
435
-							) ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ),
435
+							)), esc_url('http://docs.givewp.com/form-floating-labels')),
436 436
 							'id'   => 'floatlabels',
437 437
 							'type' => 'checkbox',
438 438
 						),
439 439
 						array(
440
-							'name' => esc_html__( 'Disable Welcome Screen', 'give' ),
440
+							'name' => esc_html__('Disable Welcome Screen', 'give'),
441 441
 							/* translators: %s: about page URL */
442
-							'desc' => sprintf( wp_kses( __( 'Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> every time Give is activated and/or updated.', 'give' ), array(
442
+							'desc' => sprintf(wp_kses(__('Enable this option if you would like to disable the <a href="%s" target="_blank">Give Welcome screen</a> every time Give is activated and/or updated.', 'give'), array(
443 443
 								'a' => array(
444 444
 									'href'   => array(),
445 445
 									'target' => array(),
446 446
 								),
447
-							) ), esc_url( admin_url( 'index.php?page=give-about' ) ) ),
447
+							)), esc_url(admin_url('index.php?page=give-about'))),
448 448
 							'id'   => 'disable_welcome',
449 449
 							'type' => 'checkbox',
450 450
 						),
451 451
 						array(
452
-							'name' => esc_html__( 'Post Types', 'give' ),
452
+							'name' => esc_html__('Post Types', 'give'),
453 453
 							'desc' => '',
454 454
 							'id'   => 'give_title_display_settings_2',
455 455
 							'type' => 'give_title',
456 456
 						),
457 457
 						array(
458
-							'name' => esc_html__( 'Disable Form Single Views', 'give' ),
459
-							'desc' => esc_html__( 'By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give' ),
458
+							'name' => esc_html__('Disable Form Single Views', 'give'),
459
+							'desc' => esc_html__('By default, all forms have single views enabled which create a specific URL on your website for that form. This option disables the singular and archive views from being publicly viewable. Note: you will need to embed forms using a shortcode or widget if enabled.', 'give'),
460 460
 							'id'   => 'disable_forms_singular',
461 461
 							'type' => 'checkbox',
462 462
 						),
463 463
 						array(
464
-							'name' => esc_html__( 'Disable Form Archives', 'give' ),
465
-							'desc' => esc_html__( 'Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give' ),
464
+							'name' => esc_html__('Disable Form Archives', 'give'),
465
+							'desc' => esc_html__('Archives pages list all the forms you have created. This option will disable only the form\'s archive page(s). The single form\'s view will remain in place. Note: you will need to refresh your permalinks after this option has been enabled.', 'give'),
466 466
 							'id'   => 'disable_forms_archives',
467 467
 							'type' => 'checkbox',
468 468
 						),
469 469
 						array(
470
-							'name' => esc_html__( 'Disable Form Excerpts', 'give' ),
471
-							'desc' => esc_html__( 'The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give' ),
470
+							'name' => esc_html__('Disable Form Excerpts', 'give'),
471
+							'desc' => esc_html__('The excerpt is an optional summary or description of a donation form; in short, a summary as to why the user should give.', 'give'),
472 472
 							'id'   => 'disable_forms_excerpt',
473 473
 							'type' => 'checkbox',
474 474
 						),
475 475
 						array(
476
-							'name'    => esc_html__( 'Featured Image Size', 'give' ),
477
-							'desc'    => esc_html__( 'The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give' ),
476
+							'name'    => esc_html__('Featured Image Size', 'give'),
477
+							'desc'    => esc_html__('The Featured Image is an image that is chosen as the representative image for a donation form. Some themes may have custom featured image sizes. Please select the size you would like to display for your single donation form\'s featured image.', 'give'),
478 478
 							'id'      => 'featured_image_size',
479 479
 							'type'    => 'select',
480 480
 							'default' => 'large',
481 481
 							'options' => give_get_featured_image_sizes(),
482 482
 						),
483 483
 						array(
484
-							'name' => esc_html__( 'Disable Form Featured Image', 'give' ),
485
-							'desc' => esc_html__( 'If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give' ),
484
+							'name' => esc_html__('Disable Form Featured Image', 'give'),
485
+							'desc' => esc_html__('If you do not wish to use the featured image functionality you can disable it using this option and it will not be displayed for single donation forms.', 'give'),
486 486
 							'id'   => 'disable_form_featured_img',
487 487
 							'type' => 'checkbox',
488 488
 						),
489 489
 						array(
490
-							'name' => esc_html__( 'Disable Single Form Sidebar', 'give' ),
491
-							'desc' => esc_html__( 'The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give' ),
490
+							'name' => esc_html__('Disable Single Form Sidebar', 'give'),
491
+							'desc' => esc_html__('The sidebar allows you to add additional widget to the Give single form view. If you don\'t plan on using the sidebar you may disable it with this option.', 'give'),
492 492
 							'id'   => 'disable_form_sidebar',
493 493
 							'type' => 'checkbox',
494 494
 						),
495 495
 						array(
496
-							'name' => esc_html__( 'Taxonomies', 'give' ),
496
+							'name' => esc_html__('Taxonomies', 'give'),
497 497
 							'desc' => '',
498 498
 							'id'   => 'give_title_display_settings_3',
499 499
 							'type' => 'give_title',
500 500
 						),
501 501
 						array(
502
-							'name' => esc_html__( 'Enable Form Categories', 'give' ),
503
-							'desc' => esc_html__( 'Enables the "Category" taxonomy for all Give forms.', 'give' ),
502
+							'name' => esc_html__('Enable Form Categories', 'give'),
503
+							'desc' => esc_html__('Enables the "Category" taxonomy for all Give forms.', 'give'),
504 504
 							'id'   => 'categories',
505 505
 							'type' => 'checkbox',
506 506
 						),
507 507
 						array(
508
-							'name' => esc_html__( 'Enable Form Tags', 'give' ),
509
-							'desc' => esc_html__( 'Enables the "Tag" taxonomy for all Give forms.', 'give' ),
508
+							'name' => esc_html__('Enable Form Tags', 'give'),
509
+							'desc' => esc_html__('Enables the "Tag" taxonomy for all Give forms.', 'give'),
510 510
 							'id'   => 'tags',
511 511
 							'type' => 'checkbox',
512 512
 						),
@@ -519,101 +519,101 @@  discard block
 block discarded – undo
519 519
 			 */
520 520
 			'emails'      => array(
521 521
 				'id'         => 'email_settings',
522
-				'give_title' => esc_html__( 'Email Settings', 'give' ),
523
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
524
-				'fields'     => apply_filters( 'give_settings_emails', array(
522
+				'give_title' => esc_html__('Email Settings', 'give'),
523
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
524
+				'fields'     => apply_filters('give_settings_emails', array(
525 525
 						array(
526
-							'name' => esc_html__( 'Email Settings', 'give' ),
526
+							'name' => esc_html__('Email Settings', 'give'),
527 527
 							'desc' => '',
528 528
 							'id'   => 'give_title_email_settings_1',
529 529
 							'type' => 'give_title',
530 530
 						),
531 531
 						array(
532 532
 							'id'      => 'email_template',
533
-							'name'    => esc_html__( 'Email Template', 'give' ),
534
-							'desc'    => esc_html__( 'Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give' ),
533
+							'name'    => esc_html__('Email Template', 'give'),
534
+							'desc'    => esc_html__('Choose a template. Click "Save Changes" then "Preview Donation Receipt" to see the new template.', 'give'),
535 535
 							'type'    => 'select',
536 536
 							'options' => give_get_email_templates(),
537 537
 						),
538 538
 						array(
539 539
 							'id'   => 'email_logo',
540
-							'name' => esc_html__( 'Logo', 'give' ),
541
-							'desc' => esc_html__( 'Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give' ),
540
+							'name' => esc_html__('Logo', 'give'),
541
+							'desc' => esc_html__('Upload or choose a logo to be displayed at the top of the donation receipt emails. Displayed on HTML emails only.', 'give'),
542 542
 							'type' => 'file',
543 543
 						),
544 544
 						array(
545 545
 							'id'      => 'from_name',
546
-							'name'    => esc_html__( 'From Name', 'give' ),
547
-							'desc'    => esc_html__( 'The name that appears in the "From" field in donation receipt emails.', 'give' ),
548
-							'default' => get_bloginfo( 'name' ),
546
+							'name'    => esc_html__('From Name', 'give'),
547
+							'desc'    => esc_html__('The name that appears in the "From" field in donation receipt emails.', 'give'),
548
+							'default' => get_bloginfo('name'),
549 549
 							'type'    => 'text',
550 550
 						),
551 551
 						array(
552 552
 							'id'      => 'from_email',
553
-							'name'    => esc_html__( 'From Email', 'give' ),
554
-							'desc'    => esc_html__( 'Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give' ),
555
-							'default' => get_bloginfo( 'admin_email' ),
553
+							'name'    => esc_html__('From Email', 'give'),
554
+							'desc'    => esc_html__('Email to send donation receipts from. This will act as the "from" and "reply-to" address.', 'give'),
555
+							'default' => get_bloginfo('admin_email'),
556 556
 							'type'    => 'text',
557 557
 						),
558 558
 						array(
559
-							'name' => esc_html__( 'Donation Receipt', 'give' ),
559
+							'name' => esc_html__('Donation Receipt', 'give'),
560 560
 							'desc' => '',
561 561
 							'id'   => 'give_title_email_settings_2',
562 562
 							'type' => 'give_title',
563 563
 						),
564 564
 						array(
565 565
 							'id'      => 'donation_subject',
566
-							'name'    => esc_html__( 'Donation Email Subject', 'give' ),
567
-							'desc'    => esc_html__( 'Enter the subject line for the donation receipt email.', 'give' ),
568
-							'default' => esc_attr__( 'Donation Receipt', 'give' ),
566
+							'name'    => esc_html__('Donation Email Subject', 'give'),
567
+							'desc'    => esc_html__('Enter the subject line for the donation receipt email.', 'give'),
568
+							'default' => esc_attr__('Donation Receipt', 'give'),
569 569
 							'type'    => 'text',
570 570
 						),
571 571
 						array(
572 572
 							'id'      => 'donation_receipt',
573
-							'name'    => esc_html__( 'Donation Receipt', 'give' ),
573
+							'name'    => esc_html__('Donation Receipt', 'give'),
574 574
 							'desc'    => sprintf(
575 575
 								/* translators: %s: emails tags list */
576
-								esc_html__( 'Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags: %s', 'give' ),
577
-								'<br/>' . give_get_emails_tags_list()
576
+								esc_html__('Enter the email that is sent to users after completing a successful donation. HTML is accepted. Available template tags: %s', 'give'),
577
+								'<br/>'.give_get_emails_tags_list()
578 578
 							),
579 579
 							'type'    => 'wysiwyg',
580 580
 							'default' => give_get_default_donation_receipt_email(),
581 581
 						),
582 582
 						array(
583
-							'name' => esc_html__( 'New Donation Notification', 'give' ),
583
+							'name' => esc_html__('New Donation Notification', 'give'),
584 584
 							'desc' => '',
585 585
 							'id'   => 'give_title_email_settings_3',
586 586
 							'type' => 'give_title',
587 587
 						),
588 588
 						array(
589 589
 							'id'      => 'donation_notification_subject',
590
-							'name'    => esc_html__( 'Donation Notification Subject', 'give' ),
591
-							'desc'    => esc_html__( 'Enter the subject line for the donation notification email.', 'give' ),
590
+							'name'    => esc_html__('Donation Notification Subject', 'give'),
591
+							'desc'    => esc_html__('Enter the subject line for the donation notification email.', 'give'),
592 592
 							'type'    => 'text',
593
-							'default' => esc_attr__( 'New Donation - #{payment_id}', 'give' ),
593
+							'default' => esc_attr__('New Donation - #{payment_id}', 'give'),
594 594
 						),
595 595
 						array(
596 596
 							'id'      => 'donation_notification',
597
-							'name'    => esc_html__( 'Donation Notification', 'give' ),
597
+							'name'    => esc_html__('Donation Notification', 'give'),
598 598
 							'desc'    => sprintf(
599 599
 								/* translators: %s: emails tags list */
600
-								esc_html__( 'Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags: %s', 'give' ),
601
-								'<br/>' . give_get_emails_tags_list()
600
+								esc_html__('Enter the email that is sent to donation notification emails after completion of a donation. HTML is accepted. Available template tags: %s', 'give'),
601
+								'<br/>'.give_get_emails_tags_list()
602 602
 							),
603 603
 							'type'    => 'wysiwyg',
604 604
 							'default' => give_get_default_donation_notification_email(),
605 605
 						),
606 606
 						array(
607 607
 							'id'      => 'admin_notice_emails',
608
-							'name'    => esc_html__( 'Donation Notification Emails', 'give' ),
609
-							'desc'    => __( 'Enter the email address(es) that should receive a notification anytime a donation is made, please only enter <span class="give-underline">one email address per line</span> and <strong>not separated by commas</strong>.', 'give' ),
608
+							'name'    => esc_html__('Donation Notification Emails', 'give'),
609
+							'desc'    => __('Enter the email address(es) that should receive a notification anytime a donation is made, please only enter <span class="give-underline">one email address per line</span> and <strong>not separated by commas</strong>.', 'give'),
610 610
 							'type'    => 'textarea',
611
-							'default' => get_bloginfo( 'admin_email' ),
611
+							'default' => get_bloginfo('admin_email'),
612 612
 						),
613 613
 						array(
614 614
 							'id'   => 'disable_admin_notices',
615
-							'name' => esc_html__( 'Disable Admin Notifications', 'give' ),
616
-							'desc' => esc_html__( 'Check this box if you do not want to receive emails when new donations are made.', 'give' ),
615
+							'name' => esc_html__('Disable Admin Notifications', 'give'),
616
+							'desc' => esc_html__('Check this box if you do not want to receive emails when new donations are made.', 'give'),
617 617
 							'type' => 'checkbox',
618 618
 						),
619 619
 					)
@@ -622,99 +622,99 @@  discard block
 block discarded – undo
622 622
 			/** Extension Settings */
623 623
 			'addons'      => array(
624 624
 				'id'         => 'addons',
625
-				'give_title' => esc_html__( 'Give Add-ons Settings', 'give' ),
626
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
627
-				'fields'     => apply_filters( 'give_settings_addons', array()
625
+				'give_title' => esc_html__('Give Add-ons Settings', 'give'),
626
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
627
+				'fields'     => apply_filters('give_settings_addons', array()
628 628
 				),
629 629
 			),
630 630
 			/** Licenses Settings */
631 631
 			'licenses'    => array(
632 632
 				'id'         => 'licenses',
633
-				'give_title' => esc_html__( 'Give Licenses', 'give' ),
634
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
635
-				'fields'     => apply_filters( 'give_settings_licenses', array()
633
+				'give_title' => esc_html__('Give Licenses', 'give'),
634
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
635
+				'fields'     => apply_filters('give_settings_licenses', array()
636 636
 				),
637 637
 			),
638 638
 			/** Advanced Options */
639 639
 			'advanced'    => array(
640 640
 				'id'         => 'advanced_options',
641
-				'give_title' => esc_html__( 'Advanced Options', 'give' ),
642
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
643
-				'fields'     => apply_filters( 'give_settings_advanced', array(
641
+				'give_title' => esc_html__('Advanced Options', 'give'),
642
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
643
+				'fields'     => apply_filters('give_settings_advanced', array(
644 644
 						array(
645
-							'name' => esc_html__( 'Access Control', 'give' ),
645
+							'name' => esc_html__('Access Control', 'give'),
646 646
 							'desc' => '',
647 647
 							'id'   => 'give_title_session_control_1',
648 648
 							'type' => 'give_title',
649 649
 						),
650 650
 						array(
651 651
 							'id'      => 'session_lifetime',
652
-							'name'    => esc_html__( 'Session Lifetime', 'give' ),
653
-							'desc'    => esc_html__( 'The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give' ),
652
+							'name'    => esc_html__('Session Lifetime', 'give'),
653
+							'desc'    => esc_html__('The length of time a user\'s session is kept alive. Give starts a new session per user upon donation. Sessions allow donors to view their donation receipts without being logged in.', 'give'),
654 654
 							'type'    => 'select',
655 655
 							'options' => array(
656
-								'86400'  => esc_html__( '24 Hours', 'give' ),
657
-								'172800' => esc_html__( '48 Hours', 'give' ),
658
-								'259200' => esc_html__( '72 Hours', 'give' ),
659
-								'604800' => esc_html__( '1 Week', 'give' ),
656
+								'86400'  => esc_html__('24 Hours', 'give'),
657
+								'172800' => esc_html__('48 Hours', 'give'),
658
+								'259200' => esc_html__('72 Hours', 'give'),
659
+								'604800' => esc_html__('1 Week', 'give'),
660 660
 							),
661 661
 						),
662 662
 						array(
663
-							'name' => esc_html__( 'Email Access', 'give' ),
664
-							'desc' => esc_html__( 'Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give' ),
663
+							'name' => esc_html__('Email Access', 'give'),
664
+							'desc' => esc_html__('Would you like your donors to be able to access their donation history using only email? Donors whose sessions have expired and do not have an account may still access their donation history via a temporary email access link.', 'give'),
665 665
 							'id'   => 'email_access',
666 666
 							'type' => 'checkbox',
667 667
 						),
668 668
 						array(
669 669
 							'id'      => 'recaptcha_key',
670
-							'name'    => esc_html__( 'reCAPTCHA Site Key', 'give' ),
670
+							'name'    => esc_html__('reCAPTCHA Site Key', 'give'),
671 671
 							/* translators: %s: https://www.google.com/recaptcha/ */
672
-							'desc'    => sprintf( __( 'If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give' ), esc_url( 'https://www.google.com/recaptcha/' ) ),
672
+							'desc'    => sprintf(__('If you would like to prevent spam on the email access form navigate to <a href="%s" target="_blank">the reCAPTCHA website</a> and sign up for an API key. The reCAPTCHA uses Google\'s user-friendly single click verification method.', 'give'), esc_url('https://www.google.com/recaptcha/')),
673 673
 							'default' => '',
674 674
 							'type'    => 'text',
675 675
 						),
676 676
 						array(
677 677
 							'id'      => 'recaptcha_secret',
678
-							'name'    => esc_html__( 'reCAPTCHA Secret Key', 'give' ),
679
-							'desc'    => esc_html__( 'Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give' ),
678
+							'name'    => esc_html__('reCAPTCHA Secret Key', 'give'),
679
+							'desc'    => esc_html__('Please paste the reCAPTCHA secret key here from your manage reCAPTCHA API Keys panel.', 'give'),
680 680
 							'default' => '',
681 681
 							'type'    => 'text',
682 682
 						),
683 683
 						array(
684
-							'name' => esc_html__( 'Data Control', 'give' ),
684
+							'name' => esc_html__('Data Control', 'give'),
685 685
 							'desc' => '',
686 686
 							'id'   => 'give_title_data_control_2',
687 687
 							'type' => 'give_title',
688 688
 						),
689 689
 						array(
690
-							'name' => esc_html__( 'Remove All Data on Uninstall?', 'give' ),
691
-							'desc' => esc_html__( 'When the plugin is deleted, completely remove all Give data.', 'give' ),
690
+							'name' => esc_html__('Remove All Data on Uninstall?', 'give'),
691
+							'desc' => esc_html__('When the plugin is deleted, completely remove all Give data.', 'give'),
692 692
 							'id'   => 'uninstall_on_delete',
693 693
 							'type' => 'checkbox',
694 694
 						),
695 695
 						array(
696
-							'name' => esc_html__( 'Filter Control', 'give' ),
696
+							'name' => esc_html__('Filter Control', 'give'),
697 697
 							'desc' => '',
698 698
 							'id'   => 'give_title_filter_control',
699 699
 							'type' => 'give_title',
700 700
 						),
701 701
 						array(
702 702
 							/* translators: %s: the_content */
703
-							'name' => sprintf( __( 'Disable %s filter', 'give' ), '<code>the_content</code>' ),
703
+							'name' => sprintf(__('Disable %s filter', 'give'), '<code>the_content</code>'),
704 704
 							/* translators: 1: https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content 2: the_content */
705
-							'desc' => sprintf( __( 'If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give' ), esc_url( 'https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content' ), '<code>the_content</code>' ),
705
+							'desc' => sprintf(__('If you are seeing extra social buttons, related posts, or other unwanted elements appearing within your forms then you can disable WordPress\' content filter. <a href="%1$s" target="_blank">Learn more</a> about %2$s filter.', 'give'), esc_url('https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content'), '<code>the_content</code>'),
706 706
 							'id'   => 'disable_the_content_filter',
707 707
 							'type' => 'checkbox',
708 708
 						),
709 709
 						array(
710
-							'name' => esc_html__( 'Script Loading', 'give' ),
710
+							'name' => esc_html__('Script Loading', 'give'),
711 711
 							'desc' => '',
712 712
 							'id'   => 'give_title_script_control',
713 713
 							'type' => 'give_title',
714 714
 						),
715 715
 						array(
716
-							'name' => esc_html__( 'Load Scripts in Footer?', 'give' ),
717
-							'desc' => esc_html__( 'Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give' ),
716
+							'name' => esc_html__('Load Scripts in Footer?', 'give'),
717
+							'desc' => esc_html__('Check this box if you would like Give to load all frontend JavaScript files in the footer.', 'give'),
718 718
 							'id'   => 'scripts_footer',
719 719
 							'type' => 'checkbox',
720 720
 						),
@@ -724,13 +724,13 @@  discard block
 block discarded – undo
724 724
 			/** API Settings */
725 725
 			'api'         => array(
726 726
 				'id'         => 'api',
727
-				'give_title' => esc_html__( 'API', 'give' ),
728
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
727
+				'give_title' => esc_html__('API', 'give'),
728
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
729 729
 				'show_names' => false, // Hide field names on the left
730
-				'fields'     => apply_filters( 'give_settings_system', array(
730
+				'fields'     => apply_filters('give_settings_system', array(
731 731
 						array(
732 732
 							'id'   => 'api',
733
-							'name' => esc_html__( 'API', 'give' ),
733
+							'name' => esc_html__('API', 'give'),
734 734
 							'type' => 'api',
735 735
 						),
736 736
 					)
@@ -739,13 +739,13 @@  discard block
 block discarded – undo
739 739
 			/** Licenses Settings */
740 740
 			'system_info' => array(
741 741
 				'id'         => 'system_info',
742
-				'give_title' => esc_html__( 'System Info', 'give' ),
743
-				'show_on'    => array( 'key' => 'options-page', 'value' => array( $this->key ) ),
744
-				'fields'     => apply_filters( 'give_settings_system', array(
742
+				'give_title' => esc_html__('System Info', 'give'),
743
+				'show_on'    => array('key' => 'options-page', 'value' => array($this->key)),
744
+				'fields'     => apply_filters('give_settings_system', array(
745 745
 						array(
746 746
 							'id'   => 'system-info-textarea',
747
-							'name' => esc_html__( 'System Info', 'give' ),
748
-							'desc' => esc_html__( 'Please copy and paste this information in your ticket when contacting support.', 'give' ),
747
+							'name' => esc_html__('System Info', 'give'),
748
+							'desc' => esc_html__('Please copy and paste this information in your ticket when contacting support.', 'give'),
749 749
 							'type' => 'system_info',
750 750
 						),
751 751
 					)
@@ -753,15 +753,15 @@  discard block
 block discarded – undo
753 753
 			),
754 754
 		);
755 755
 
756
-		$give_settings = apply_filters( 'give_registered_settings', $give_settings );
756
+		$give_settings = apply_filters('give_registered_settings', $give_settings);
757 757
 
758 758
 		// Return all settings array if no active tab
759
-		if ( empty( $active_tab ) || ! isset( $give_settings[ $active_tab ] ) ) {
759
+		if (empty($active_tab) || ! isset($give_settings[$active_tab])) {
760 760
 			return $give_settings;
761 761
 		}
762 762
 
763 763
 		// Add other tabs and settings fields as needed
764
-		return $give_settings[ $active_tab ];
764
+		return $give_settings[$active_tab];
765 765
 
766 766
 	}
767 767
 
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
 	 */
771 771
 	public function settings_notices() {
772 772
 
773
-		if ( ! isset( $_POST['give_settings_saved'] ) ) {
773
+		if ( ! isset($_POST['give_settings_saved'])) {
774 774
 			return;
775 775
 		}
776 776
 
777
-		add_settings_error( 'give-notices', 'global-settings-updated', esc_html__( 'Settings updated.', 'give' ), 'updated' );
777
+		add_settings_error('give-notices', 'global-settings-updated', esc_html__('Settings updated.', 'give'), 'updated');
778 778
 
779 779
 	}
780 780
 
@@ -789,14 +789,14 @@  discard block
 block discarded – undo
789 789
 	 * @return mixed         Field value or exception is thrown.
790 790
 	 * @throws Exception     Throws an exception if the field is invalid.
791 791
 	 */
792
-	public function __get( $field ) {
792
+	public function __get($field) {
793 793
 
794 794
 		// Allowed fields to retrieve
795
-		if ( in_array( $field, array( 'key', 'fields', 'give_title', 'options_page' ), true ) ) {
795
+		if (in_array($field, array('key', 'fields', 'give_title', 'options_page'), true)) {
796 796
 			return $this->{$field};
797 797
 		}
798 798
 
799
-		throw new Exception( sprintf( esc_html__( 'Invalid property: %s', 'give' ), $field ) );
799
+		throw new Exception(sprintf(esc_html__('Invalid property: %s', 'give'), $field));
800 800
 	}
801 801
 
802 802
 
@@ -815,12 +815,12 @@  discard block
 block discarded – undo
815 815
  *
816 816
  * @return mixed        Option value
817 817
  */
818
-function give_get_option( $key = '', $default = false ) {
818
+function give_get_option($key = '', $default = false) {
819 819
 	$give_options = give_get_settings();
820
-	$value        = ! empty( $give_options[ $key ] ) ? $give_options[ $key ] : $default;
821
-	$value        = apply_filters( 'give_get_option', $value, $key, $default );
820
+	$value        = ! empty($give_options[$key]) ? $give_options[$key] : $default;
821
+	$value        = apply_filters('give_get_option', $value, $key, $default);
822 822
 
823
-	return apply_filters( "give_get_option_{$key}", $value, $key, $default );
823
+	return apply_filters("give_get_option_{$key}", $value, $key, $default);
824 824
 }
825 825
 
826 826
 
@@ -838,33 +838,33 @@  discard block
 block discarded – undo
838 838
  *
839 839
  * @return boolean True if updated, false if not.
840 840
  */
841
-function give_update_option( $key = '', $value = false ) {
841
+function give_update_option($key = '', $value = false) {
842 842
 
843 843
 	// If no key, exit
844
-	if ( empty( $key ) ) {
844
+	if (empty($key)) {
845 845
 		return false;
846 846
 	}
847 847
 
848
-	if ( empty( $value ) ) {
849
-		$remove_option = give_delete_option( $key );
848
+	if (empty($value)) {
849
+		$remove_option = give_delete_option($key);
850 850
 
851 851
 		return $remove_option;
852 852
 	}
853 853
 
854 854
 	// First let's grab the current settings
855
-	$options = get_option( 'give_settings' );
855
+	$options = get_option('give_settings');
856 856
 
857 857
 	// Let's let devs alter that value coming in
858
-	$value = apply_filters( 'give_update_option', $value, $key );
858
+	$value = apply_filters('give_update_option', $value, $key);
859 859
 
860 860
 	// Next let's try to update the value
861
-	$options[ $key ] = $value;
862
-	$did_update      = update_option( 'give_settings', $options );
861
+	$options[$key] = $value;
862
+	$did_update      = update_option('give_settings', $options);
863 863
 
864 864
 	// If it updated, let's update the global variable
865
-	if ( $did_update ) {
865
+	if ($did_update) {
866 866
 		global $give_options;
867
-		$give_options[ $key ] = $value;
867
+		$give_options[$key] = $value;
868 868
 	}
869 869
 
870 870
 	return $did_update;
@@ -883,27 +883,27 @@  discard block
 block discarded – undo
883 883
  *
884 884
  * @return boolean True if updated, false if not.
885 885
  */
886
-function give_delete_option( $key = '' ) {
886
+function give_delete_option($key = '') {
887 887
 
888 888
 	// If no key, exit
889
-	if ( empty( $key ) ) {
889
+	if (empty($key)) {
890 890
 		return false;
891 891
 	}
892 892
 
893 893
 	// First let's grab the current settings
894
-	$options = get_option( 'give_settings' );
894
+	$options = get_option('give_settings');
895 895
 
896 896
 	// Next let's try to update the value
897
-	if ( isset( $options[ $key ] ) ) {
897
+	if (isset($options[$key])) {
898 898
 
899
-		unset( $options[ $key ] );
899
+		unset($options[$key]);
900 900
 
901 901
 	}
902 902
 
903
-	$did_update = update_option( 'give_settings', $options );
903
+	$did_update = update_option('give_settings', $options);
904 904
 
905 905
 	// If it updated, let's update the global variable
906
-	if ( $did_update ) {
906
+	if ($did_update) {
907 907
 		global $give_options;
908 908
 		$give_options = $options;
909 909
 	}
@@ -922,9 +922,9 @@  discard block
 block discarded – undo
922 922
  */
923 923
 function give_get_settings() {
924 924
 
925
-	$settings = get_option( 'give_settings' );
925
+	$settings = get_option('give_settings');
926 926
 
927
-	return (array) apply_filters( 'give_get_settings', $settings );
927
+	return (array) apply_filters('give_get_settings', $settings);
928 928
 
929 929
 }
930 930
 
@@ -942,25 +942,25 @@  discard block
 block discarded – undo
942 942
  *
943 943
  * @return array
944 944
  */
945
-function give_settings_array_insert( $array, $position, $insert ) {
946
-	if ( is_int( $position ) ) {
947
-		array_splice( $array, $position, 0, $insert );
945
+function give_settings_array_insert($array, $position, $insert) {
946
+	if (is_int($position)) {
947
+		array_splice($array, $position, 0, $insert);
948 948
 	} else {
949 949
 
950
-		foreach ( $array as $index => $subarray ) {
951
-			if ( isset( $subarray['id'] ) && $subarray['id'] == $position ) {
950
+		foreach ($array as $index => $subarray) {
951
+			if (isset($subarray['id']) && $subarray['id'] == $position) {
952 952
 				$pos = $index;
953 953
 			}
954 954
 		}
955 955
 
956
-		if ( ! isset( $pos ) ) {
956
+		if ( ! isset($pos)) {
957 957
 			return $array;
958 958
 		}
959 959
 
960 960
 		$array = array_merge(
961
-			array_slice( $array, 0, $pos ),
961
+			array_slice($array, 0, $pos),
962 962
 			$insert,
963
-			array_slice( $array, $pos )
963
+			array_slice($array, $pos)
964 964
 		);
965 965
 	}
966 966
 
@@ -980,23 +980,23 @@  discard block
 block discarded – undo
980 980
  *
981 981
  * @return void
982 982
  */
983
-function give_enabled_gateways_callback( $field_arr, $saved_values = array() ) {
983
+function give_enabled_gateways_callback($field_arr, $saved_values = array()) {
984 984
 
985 985
 	$id       = $field_arr['id'];
986
-	$gateways = give_get_ordered_payment_gateways( give_get_payment_gateways() );
986
+	$gateways = give_get_ordered_payment_gateways(give_get_payment_gateways());
987 987
 
988 988
 	echo '<ul class="give-checklist-fields give-payment-gatways-list">';
989 989
 
990
-	foreach ( $gateways as $key => $option ) :
990
+	foreach ($gateways as $key => $option) :
991 991
 
992
-		if ( is_array( $saved_values ) && array_key_exists( $key, $saved_values ) ) {
992
+		if (is_array($saved_values) && array_key_exists($key, $saved_values)) {
993 993
 			$enabled = '1';
994 994
 		} else {
995 995
 			$enabled = null;
996 996
 		}
997 997
 
998
-		echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="' . $id . '[' . $key . ']" id="' . $id . '[' . $key . ']" type="checkbox" value="1" ' . checked( '1', $enabled, false ) . '/>&nbsp;';
999
-		echo '<label for="' . $id . '[' . $key . ']">' . $option['admin_label'] . '</label></li>';
998
+		echo '<li><span class="give-drag-handle"><span class="dashicons dashicons-menu"></span></span><input name="'.$id.'['.$key.']" id="'.$id.'['.$key.']" type="checkbox" value="1" '.checked('1', $enabled, false).'/>&nbsp;';
999
+		echo '<label for="'.$id.'['.$key.']">'.$option['admin_label'].'</label></li>';
1000 1000
 
1001 1001
 	endforeach;
1002 1002
 
@@ -1015,16 +1015,16 @@  discard block
 block discarded – undo
1015 1015
  *
1016 1016
  * @return void
1017 1017
  */
1018
-function give_default_gateway_callback( $field_arr, $saved_value ) {
1018
+function give_default_gateway_callback($field_arr, $saved_value) {
1019 1019
 	$id          = $field_arr['id'];
1020 1020
 	$gateways    = give_get_enabled_payment_gateways();
1021
-	$saved_value = give_get_default_gateway( null );
1021
+	$saved_value = give_get_default_gateway(null);
1022 1022
 
1023
-	echo '<select class="give-select" name="' . $id . '" id="' . $id . '">';
1023
+	echo '<select class="give-select" name="'.$id.'" id="'.$id.'">';
1024 1024
 
1025
-	foreach ( $gateways as $key => $option ) :
1026
-		$selected = isset( $saved_value ) ? selected( $key, $saved_value, false ) : '';
1027
-		echo '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1025
+	foreach ($gateways as $key => $option) :
1026
+		$selected = isset($saved_value) ? selected($key, $saved_value, false) : '';
1027
+		echo '<option value="'.esc_attr($key).'"'.$selected.'>'.esc_html($option['admin_label']).'</option>';
1028 1028
 	endforeach;
1029 1029
 
1030 1030
 	echo '</select>';
@@ -1042,13 +1042,13 @@  discard block
 block discarded – undo
1042 1042
  *
1043 1043
  * @return void
1044 1044
  */
1045
-function give_title_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1045
+function give_title_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1046 1046
 
1047 1047
 	$id                = $field_type_object->field->args['id'];
1048 1048
 	$title             = $field_type_object->field->args['name'];
1049 1049
 	$field_description = $field_type_object->field->args['desc'];
1050 1050
 
1051
-	echo '<hr>' . $field_description;
1051
+	echo '<hr>'.$field_description;
1052 1052
 
1053 1053
 }
1054 1054
 
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
  *
1064 1064
  * @return void
1065 1065
  */
1066
-function give_description_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1066
+function give_description_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1067 1067
 
1068 1068
 	$id                = $field_type_object->field->args['id'];
1069 1069
 	$title             = $field_type_object->field->args['name'];
@@ -1082,25 +1082,25 @@  discard block
 block discarded – undo
1082 1082
  * @see: https://github.com/WebDevStudios/CMB2/wiki/Adding-your-own-field-types
1083 1083
  * @return array An array of options that matches the CMB2 options array
1084 1084
  */
1085
-function give_cmb2_get_post_options( $query_args, $force = false ) {
1085
+function give_cmb2_get_post_options($query_args, $force = false) {
1086 1086
 
1087
-	$post_options = array( '' => '' ); // Blank option
1087
+	$post_options = array('' => ''); // Blank option
1088 1088
 
1089
-	if ( ( ! isset( $_GET['page'] ) || 'give-settings' != $_GET['page'] ) && ! $force ) {
1089
+	if (( ! isset($_GET['page']) || 'give-settings' != $_GET['page']) && ! $force) {
1090 1090
 		return $post_options;
1091 1091
 	}
1092 1092
 
1093
-	$args = wp_parse_args( $query_args, array(
1093
+	$args = wp_parse_args($query_args, array(
1094 1094
 		'post_type'   => 'page',
1095 1095
 		'numberposts' => 10,
1096
-	) );
1096
+	));
1097 1097
 
1098
-	$posts = get_posts( $args );
1098
+	$posts = get_posts($args);
1099 1099
 
1100
-	if ( $posts ) {
1101
-		foreach ( $posts as $post ) {
1100
+	if ($posts) {
1101
+		foreach ($posts as $post) {
1102 1102
 
1103
-			$post_options[ $post->ID ] = $post->post_title;
1103
+			$post_options[$post->ID] = $post->post_title;
1104 1104
 
1105 1105
 		}
1106 1106
 	}
@@ -1126,20 +1126,20 @@  discard block
 block discarded – undo
1126 1126
 	$get_sizes = get_intermediate_image_sizes();
1127 1127
 
1128 1128
 	// check whether intermediate image sizes exist first
1129
-	if ( empty( $get_sizes ) ) {
1130
-		$get_sizes = array( 'thumbnail', 'medium', 'medium_large', 'large' );
1129
+	if (empty($get_sizes)) {
1130
+		$get_sizes = array('thumbnail', 'medium', 'medium_large', 'large');
1131 1131
 	}
1132 1132
 
1133
-	foreach ( $get_sizes as $_size ) {
1133
+	foreach ($get_sizes as $_size) {
1134 1134
 
1135
-		if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) {
1136
-			$sizes[ $_size ] = $_size . ' - ' . get_option( "{$_size}_size_w" ) . 'x' . get_option( "{$_size}_size_h" );
1137
-		} elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
1138
-			$sizes[ $_size ] = $_size . ' - ' . $_wp_additional_image_sizes[ $_size ]['width'] . 'x' . $_wp_additional_image_sizes[ $_size ]['height'];
1135
+		if (in_array($_size, array('thumbnail', 'medium', 'medium_large', 'large'))) {
1136
+			$sizes[$_size] = $_size.' - '.get_option("{$_size}_size_w").'x'.get_option("{$_size}_size_h");
1137
+		} elseif (isset($_wp_additional_image_sizes[$_size])) {
1138
+			$sizes[$_size] = $_size.' - '.$_wp_additional_image_sizes[$_size]['width'].'x'.$_wp_additional_image_sizes[$_size]['height'];
1139 1139
 		}
1140 1140
 	}
1141 1141
 
1142
-	return apply_filters( 'give_get_featured_image_sizes', $sizes );
1142
+	return apply_filters('give_get_featured_image_sizes', $sizes);
1143 1143
 }
1144 1144
 
1145 1145
 
@@ -1154,18 +1154,18 @@  discard block
 block discarded – undo
1154 1154
  *
1155 1155
  * @return void
1156 1156
  */
1157
-function give_license_key_callback( $field_object, $escaped_value, $object_id, $object_type, $field_type_object ) {
1157
+function give_license_key_callback($field_object, $escaped_value, $object_id, $object_type, $field_type_object) {
1158 1158
 	/* @var CMB2_Types $field_type_object */
1159 1159
 
1160 1160
 	$id                 = $field_type_object->field->args['id'];
1161 1161
 	$field_description  = $field_type_object->field->args['desc'];
1162 1162
 	$license            = $field_type_object->field->args['options']['license'];
1163 1163
 	$license_key        = $escaped_value;
1164
-	$is_license_key     = apply_filters( 'give_is_license_key', ( is_object( $license ) && ! empty( $license ) ) );
1165
-	$is_valid_license   = apply_filters( 'give_is_valid_license', ( $is_license_key && property_exists( $license, 'license' ) && 'valid' === $license->license ) );
1164
+	$is_license_key     = apply_filters('give_is_license_key', (is_object($license) && ! empty($license)));
1165
+	$is_valid_license   = apply_filters('give_is_valid_license', ($is_license_key && property_exists($license, 'license') && 'valid' === $license->license));
1166 1166
 	$shortname          = $field_type_object->field->args['options']['shortname'];
1167 1167
 	$field_classes      = 'regular-text give-license-field';
1168
-	$type               = empty( $escaped_value ) || ! $is_valid_license ? 'text' : 'password';
1168
+	$type               = empty($escaped_value) || ! $is_valid_license ? 'text' : 'password';
1169 1169
 	$custom_html        = '';
1170 1170
 	$messages           = array();
1171 1171
 	$class              = '';
@@ -1177,135 +1177,135 @@  discard block
 block discarded – undo
1177 1177
 
1178 1178
 	// By default query on edd api url will return license object which contain status and message property, this can break below functionality.
1179 1179
 	// To combat that check if status is set to error or not, if yes then set $is_license_key to false.
1180
-	if ( $is_license_key && property_exists( $license, 'status' ) && 'error' === $license->status ) {
1180
+	if ($is_license_key && property_exists($license, 'status') && 'error' === $license->status) {
1181 1181
 		$is_license_key = false;
1182 1182
 	}
1183 1183
 
1184 1184
 	// Check if current license is part of subscription or not.
1185
-	$subscriptions = get_option( 'give_subscriptions' );
1185
+	$subscriptions = get_option('give_subscriptions');
1186 1186
 
1187
-	if ( $is_license_key && $subscriptions ) {
1188
-		foreach ( $subscriptions as $subscription ) {
1189
-			if ( in_array( $license_key, $subscription['licenses'] ) ) {
1187
+	if ($is_license_key && $subscriptions) {
1188
+		foreach ($subscriptions as $subscription) {
1189
+			if (in_array($license_key, $subscription['licenses'])) {
1190 1190
 				$is_in_subscription = $subscription['id'];
1191 1191
 				break;
1192 1192
 			}
1193 1193
 		}
1194 1194
 	}
1195 1195
 
1196
-	if ( $is_license_key ) {
1197
-		if ( $is_in_subscription ) {
1198
-			$subscription_expires = strtotime( $subscriptions[ $is_in_subscription ]['expires'] );
1199
-			$subscription_status  = esc_html__( 'renew', 'give' );
1196
+	if ($is_license_key) {
1197
+		if ($is_in_subscription) {
1198
+			$subscription_expires = strtotime($subscriptions[$is_in_subscription]['expires']);
1199
+			$subscription_status  = esc_html__('renew', 'give');
1200 1200
 
1201
-			if ( ( 'active' !== $subscriptions[ $is_in_subscription ]['status'] ) ) {
1202
-				$subscription_status = esc_html__( 'expire', 'give' );
1201
+			if (('active' !== $subscriptions[$is_in_subscription]['status'])) {
1202
+				$subscription_status = esc_html__('expire', 'give');
1203 1203
 			}
1204 1204
 
1205
-			if ( $subscription_expires < current_time( 'timestamp', 1 ) ) {
1206
-				$messages[]     = sprintf(
1207
-					__( 'Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) expired. Please <a href="%3$s" target="_blank" title="Renew your license key">renew your license key</a>', 'give' ),
1208
-					urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ),
1209
-					$subscriptions[ $is_in_subscription ]['payment_id'],
1210
-					$checkout_page_link . '?edd_license_key=' . $subscriptions[ $is_in_subscription ]['license_key'] . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
1205
+			if ($subscription_expires < current_time('timestamp', 1)) {
1206
+				$messages[] = sprintf(
1207
+					__('Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) expired. Please <a href="%3$s" target="_blank" title="Renew your license key">renew your license key</a>', 'give'),
1208
+					urldecode($subscriptions[$is_in_subscription]['invoice_url']),
1209
+					$subscriptions[$is_in_subscription]['payment_id'],
1210
+					$checkout_page_link.'?edd_license_key='.$subscriptions[$is_in_subscription]['license_key'].'&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
1211 1211
 				);
1212 1212
 				$license_status = 'license-expired';
1213
-			} elseif ( strtotime( '- 7 days', $subscription_expires ) < current_time( 'timestamp', 1 ) ) {
1213
+			} elseif (strtotime('- 7 days', $subscription_expires) < current_time('timestamp', 1)) {
1214 1214
 				$messages[]     = sprintf(
1215
-					__( 'Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s in %4$s.', 'give' ),
1216
-					urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ),
1217
-					$subscriptions[ $is_in_subscription ]['payment_id'],
1215
+					__('Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s in %4$s.', 'give'),
1216
+					urldecode($subscriptions[$is_in_subscription]['invoice_url']),
1217
+					$subscriptions[$is_in_subscription]['payment_id'],
1218 1218
 					$subscription_status,
1219
-					human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscriptions[ $is_in_subscription ]['expires'] ) )
1219
+					human_time_diff(current_time('timestamp', 1), strtotime($subscriptions[$is_in_subscription]['expires']))
1220 1220
 				);
1221 1221
 				$license_status = 'license-expires-soon';
1222 1222
 			} else {
1223 1223
 				$messages[]     = sprintf(
1224
-					__( 'Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s on %4$s.', 'give' ),
1225
-					urldecode( $subscriptions[ $is_in_subscription ]['invoice_url'] ),
1226
-					$subscriptions[ $is_in_subscription ]['payment_id'],
1224
+					__('Your subscription (<a href="%1$s" target="_blank">#%2$d</a>) will %3$s on %4$s.', 'give'),
1225
+					urldecode($subscriptions[$is_in_subscription]['invoice_url']),
1226
+					$subscriptions[$is_in_subscription]['payment_id'],
1227 1227
 					$subscription_status,
1228
-					date_i18n( get_option( 'date_format' ), strtotime( $subscriptions[ $is_in_subscription ]['expires'], current_time( 'timestamp' ) ) )
1228
+					date_i18n(get_option('date_format'), strtotime($subscriptions[$is_in_subscription]['expires'], current_time('timestamp')))
1229 1229
 				);
1230 1230
 				$license_status = 'license-expiration-date';
1231 1231
 			}
1232
-		} elseif ( empty( $license->success ) && property_exists( $license, 'error' ) ) {
1232
+		} elseif (empty($license->success) && property_exists($license, 'error')) {
1233 1233
 
1234 1234
 			// activate_license 'invalid' on anything other than valid, so if there was an error capture it
1235
-			switch ( $license->error ) {
1235
+			switch ($license->error) {
1236 1236
 				case 'expired' :
1237 1237
 					$class          = $license->error;
1238 1238
 					$messages[]     = sprintf(
1239
-						__( 'Your license key expired on %1$s. Please <a href="%2$s" target="_blank" title="Renew your license key">renew your license key</a>.', 'give' ),
1240
-						date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
1241
-						$checkout_page_link . '?edd_license_key=' . $license_key . '&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
1239
+						__('Your license key expired on %1$s. Please <a href="%2$s" target="_blank" title="Renew your license key">renew your license key</a>.', 'give'),
1240
+						date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))),
1241
+						$checkout_page_link.'?edd_license_key='.$license_key.'&utm_campaign=admin&utm_source=licenses&utm_medium=expired'
1242 1242
 					);
1243
-					$license_status = 'license-' . $class;
1243
+					$license_status = 'license-'.$class;
1244 1244
 					break;
1245 1245
 
1246 1246
 				case 'missing' :
1247 1247
 					$class          = $license->error;
1248 1248
 					$messages[]     = sprintf(
1249
-						__( 'Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'give' ),
1250
-						$account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
1249
+						__('Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'give'),
1250
+						$account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=missing'
1251 1251
 					);
1252
-					$license_status = 'license-' . $class;
1252
+					$license_status = 'license-'.$class;
1253 1253
 					break;
1254 1254
 
1255 1255
 				case 'invalid' :
1256 1256
 					$class          = $license->error;
1257 1257
 					$messages[]     = sprintf(
1258
-						__( 'Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give' ),
1258
+						__('Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give'),
1259 1259
 						$addon_name,
1260
-						$account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
1260
+						$account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
1261 1261
 					);
1262
-					$license_status = 'license-' . $class;
1262
+					$license_status = 'license-'.$class;
1263 1263
 					break;
1264 1264
 
1265 1265
 				case 'site_inactive' :
1266 1266
 					$class          = $license->error;
1267 1267
 					$messages[]     = sprintf(
1268
-						__( 'Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give' ),
1268
+						__('Your %1$s is not active for this URL. Please <a href="%2$s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'give'),
1269 1269
 						$addon_name,
1270
-						$account_page_link . '?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
1270
+						$account_page_link.'?utm_campaign=admin&utm_source=licenses&utm_medium=invalid'
1271 1271
 					);
1272
-					$license_status = 'license-' . $class;
1272
+					$license_status = 'license-'.$class;
1273 1273
 					break;
1274 1274
 
1275 1275
 				case 'item_name_mismatch' :
1276 1276
 					$class          = $license->error;
1277
-					$messages[]     = sprintf( __( 'This license %1$s does not belong to %2$s.', 'give' ), $license_key, $addon_name );
1278
-					$license_status = 'license-' . $class;
1277
+					$messages[]     = sprintf(__('This license %1$s does not belong to %2$s.', 'give'), $license_key, $addon_name);
1278
+					$license_status = 'license-'.$class;
1279 1279
 					break;
1280 1280
 
1281 1281
 				case 'no_activations_left':
1282 1282
 					$class          = $license->error;
1283
-					$messages[]     = sprintf( __( 'Your license key has reached it\'s activation limit. <a href="%s">View possible upgrades</a> now.', 'give' ), $account_page_link );
1284
-					$license_status = 'license-' . $class;
1283
+					$messages[]     = sprintf(__('Your license key has reached it\'s activation limit. <a href="%s">View possible upgrades</a> now.', 'give'), $account_page_link);
1284
+					$license_status = 'license-'.$class;
1285 1285
 					break;
1286 1286
 			}
1287 1287
 		} else {
1288
-			switch ( $license->license ) {
1288
+			switch ($license->license) {
1289 1289
 				case 'valid' :
1290 1290
 				default:
1291 1291
 					$class      = 'valid';
1292
-					$now        = current_time( 'timestamp' );
1293
-					$expiration = strtotime( $license->expires, current_time( 'timestamp' ) );
1292
+					$now        = current_time('timestamp');
1293
+					$expiration = strtotime($license->expires, current_time('timestamp'));
1294 1294
 
1295
-					if ( 'lifetime' === $license->expires ) {
1296
-						$messages[]     = esc_html__( 'License key never expires.', 'give' );
1295
+					if ('lifetime' === $license->expires) {
1296
+						$messages[]     = esc_html__('License key never expires.', 'give');
1297 1297
 						$license_status = 'license-lifetime-notice';
1298
-					} elseif ( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
1298
+					} elseif ($expiration > $now && $expiration - $now < (DAY_IN_SECONDS * 30)) {
1299 1299
 						$messages[]     = sprintf(
1300
-							__( 'Your license key expires soon! It expires on %1$s. <a href="%2$s" target="_blank" title="Renew license">Renew your license key</a>.', 'give' ),
1301
-							date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ),
1302
-							$checkout_page_link . '?edd_license_key=' . $license_key . '&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
1300
+							__('Your license key expires soon! It expires on %1$s. <a href="%2$s" target="_blank" title="Renew license">Renew your license key</a>.', 'give'),
1301
+							date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp'))),
1302
+							$checkout_page_link.'?edd_license_key='.$license_key.'&utm_campaign=admin&utm_source=licenses&utm_medium=renew'
1303 1303
 						);
1304 1304
 						$license_status = 'license-expires-soon';
1305 1305
 					} else {
1306 1306
 						$messages[]     = sprintf(
1307
-							__( 'Your license key expires on %s.', 'give' ),
1308
-							date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
1307
+							__('Your license key expires on %s.', 'give'),
1308
+							date_i18n(get_option('date_format'), strtotime($license->expires, current_time('timestamp')))
1309 1309
 						);
1310 1310
 						$license_status = 'license-expiration-date';
1311 1311
 					}
@@ -1313,15 +1313,15 @@  discard block
 block discarded – undo
1313 1313
 			}
1314 1314
 		}
1315 1315
 	} else {
1316
-		$messages[]     = sprintf(
1317
-			__( 'To receive updates, please enter your valid %s license key.', 'give' ),
1316
+		$messages[] = sprintf(
1317
+			__('To receive updates, please enter your valid %s license key.', 'give'),
1318 1318
 			$addon_name
1319 1319
 		);
1320 1320
 		$license_status = 'inactive';
1321 1321
 	}
1322 1322
 
1323 1323
 	// Add class for input field if license is active.
1324
-	if ( $is_valid_license ) {
1324
+	if ($is_valid_license) {
1325 1325
 		$field_classes .= ' give-license-active';
1326 1326
 	}
1327 1327
 
@@ -1329,33 +1329,33 @@  discard block
 block discarded – undo
1329 1329
 	$input_field_html = "<input type=\"{$type}\" name=\"{$id}\" class=\"{$field_classes}\" value=\"{$license_key}\">";
1330 1330
 
1331 1331
 	// If license is active so show deactivate button.
1332
-	if ( $is_valid_license ) {
1332
+	if ($is_valid_license) {
1333 1333
 		// Get input field html.
1334 1334
 		$input_field_html = "<input type=\"{$type}\" name=\"{$id}\" class=\"{$field_classes}\" value=\"{$license_key}\" readonly=\"readonly\">";
1335 1335
 
1336
-		$custom_html = '<input type="submit" class="button button-small give-license-deactivate" name="' . $id . '_deactivate" value="' . esc_attr__( 'Deactivate License', 'give' ) . '"/>';
1336
+		$custom_html = '<input type="submit" class="button button-small give-license-deactivate" name="'.$id.'_deactivate" value="'.esc_attr__('Deactivate License', 'give').'"/>';
1337 1337
 
1338 1338
 	}
1339 1339
 
1340 1340
 	// Field description.
1341
-	$custom_html .= '<label for="give_settings[' . $id . ']"> ' . $field_description . '</label>';
1341
+	$custom_html .= '<label for="give_settings['.$id.']"> '.$field_description.'</label>';
1342 1342
 
1343 1343
 	// If no messages found then inform user that to get updated in future register yourself.
1344
-	if ( empty( $messages ) ) {
1345
-		$messages[] = apply_filters( "{$shortname}_default_addon_notice", esc_html__( 'To receive updates, please enter your valid license key.', 'give' ) );
1344
+	if (empty($messages)) {
1345
+		$messages[] = apply_filters("{$shortname}_default_addon_notice", esc_html__('To receive updates, please enter your valid license key.', 'give'));
1346 1346
 	}
1347 1347
 
1348
-	foreach ( $messages as $message ) {
1349
-		$custom_html .= '<div class="give-license-status-notice give-' . $license_status . '">';
1350
-		$custom_html .= '<p>' . $message . '</p>';
1348
+	foreach ($messages as $message) {
1349
+		$custom_html .= '<div class="give-license-status-notice give-'.$license_status.'">';
1350
+		$custom_html .= '<p>'.$message.'</p>';
1351 1351
 		$custom_html .= '</div>';
1352 1352
 	}
1353 1353
 
1354 1354
 	// Field html.
1355
-	$custom_html = apply_filters( 'give_license_key_field_html', $input_field_html . $custom_html, $field_type_object );
1355
+	$custom_html = apply_filters('give_license_key_field_html', $input_field_html.$custom_html, $field_type_object);
1356 1356
 
1357 1357
 	// Nonce.
1358
-	wp_nonce_field( $id . '-nonce', $id . '-nonce' );
1358
+	wp_nonce_field($id.'-nonce', $id.'-nonce');
1359 1359
 
1360 1360
 	// Print field html.
1361 1361
 	echo "<div class=\"give-license-key\"><label for=\"{$id}\">{$addon_name }</label></div><div class=\"give-license-block\">{$custom_html}</div>";
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
  */
1371 1371
 function give_api_callback() {
1372 1372
 
1373
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
1373
+	if ( ! current_user_can('manage_give_settings')) {
1374 1374
 		return;
1375 1375
 	}
1376 1376
 
@@ -1379,9 +1379,9 @@  discard block
 block discarded – undo
1379 1379
 	 *
1380 1380
 	 * @since 1.0
1381 1381
 	 */
1382
-	do_action( 'give_tools_api_keys_before' );
1382
+	do_action('give_tools_api_keys_before');
1383 1383
 
1384
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/class-api-keys-table.php';
1384
+	require_once GIVE_PLUGIN_DIR.'includes/admin/class-api-keys-table.php';
1385 1385
 
1386 1386
 	$api_keys_table = new Give_API_Keys_Table();
1387 1387
 	$api_keys_table->prepare_items();
@@ -1390,9 +1390,9 @@  discard block
 block discarded – undo
1390 1390
 	<span class="cmb2-metabox-description api-description">
1391 1391
 		<?php echo sprintf(
1392 1392
 			/* translators: 1: http://docs.givewp.com/api 2: http://docs.givewp.com/addon-zapier */
1393
-			__( 'You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give' ),
1394
-			esc_url( 'http://docs.givewp.com/api' ),
1395
-			esc_url( 'http://docs.givewp.com/addon-zapier' )
1393
+			__('You can create API keys for individual users within their profile edit screen. API keys allow users to use the <a href="%1$s" target="_blank">Give REST API</a> to retrieve donation data in JSON or XML for external applications or devices, such as <a href="%2$s" target="_blank">Zapier</a>.', 'give'),
1394
+			esc_url('http://docs.givewp.com/api'),
1395
+			esc_url('http://docs.givewp.com/addon-zapier')
1396 1396
 		); ?>
1397 1397
 	</span>
1398 1398
 	<?php
@@ -1402,10 +1402,10 @@  discard block
 block discarded – undo
1402 1402
 	 *
1403 1403
 	 * @since 1.0
1404 1404
 	 */
1405
-	do_action( 'give_tools_api_keys_after' );
1405
+	do_action('give_tools_api_keys_after');
1406 1406
 }
1407 1407
 
1408
-add_action( 'give_settings_tab_api_keys', 'give_api_callback' );
1408
+add_action('give_settings_tab_api_keys', 'give_api_callback');
1409 1409
 
1410 1410
 /**
1411 1411
  * Hook Callback
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
  *
1419 1419
  * @return void
1420 1420
  */
1421
-function give_hook_callback( $args ) {
1421
+function give_hook_callback($args) {
1422 1422
 
1423 1423
 	$id = $args['id'];
1424 1424
 
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
 	 *
1428 1428
 	 * @since 1.0
1429 1429
 	 */
1430
-	do_action( "give_{$id}" );
1430
+	do_action("give_{$id}");
1431 1431
 
1432 1432
 }
1433 1433
 
@@ -1442,19 +1442,19 @@  discard block
 block discarded – undo
1442 1442
  *
1443 1443
  * @return bool
1444 1444
  */
1445
-function give_is_setting_enabled( $value, $compare_with = null ) {
1446
-	if ( ! is_null( $compare_with ) ) {
1445
+function give_is_setting_enabled($value, $compare_with = null) {
1446
+	if ( ! is_null($compare_with)) {
1447 1447
 
1448
-		if ( is_array( $compare_with ) ) {
1448
+		if (is_array($compare_with)) {
1449 1449
 			// Output.
1450
-			return in_array( $value, $compare_with );
1450
+			return in_array($value, $compare_with);
1451 1451
 		}
1452 1452
 
1453 1453
 		// Output.
1454
-		return ( $value === $compare_with );
1454
+		return ($value === $compare_with);
1455 1455
 	}
1456 1456
 
1457 1457
 	// Backward compatibility: From version 1.8 most of setting is modified to enabled/disabled
1458 1458
 	// Output.
1459
-	return ( in_array( $value, array( 'enabled', 'on', 'yes' ) ) ? true : false );
1459
+	return (in_array($value, array('enabled', 'on', 'yes')) ? true : false);
1460 1460
 }
Please login to merge, or discard this patch.
includes/class-give-customer.php 1 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();
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 		}
205 205
 
206 206
 		// Get donor's all email including primary email.
207
-		$this->emails   = (array) $this->get_meta( 'additional_email', false );
208
-		$this->emails = array( 'primary' => $this->email ) + $this->emails;
207
+		$this->emails = (array) $this->get_meta('additional_email', false);
208
+		$this->emails = array('primary' => $this->email) + $this->emails;
209 209
 
210 210
 		// Customer ID and email are the only things that are necessary, make sure they exist.
211
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
211
+		if ( ! empty($this->id) && ! empty($this->email)) {
212 212
 			return true;
213 213
 		}
214 214
 
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
 	 * @since  1.0
223 223
 	 * @access public
224 224
 	 */
225
-	public function __get( $key ) {
225
+	public function __get($key) {
226 226
 
227
-		if ( method_exists( $this, 'get_' . $key ) ) {
227
+		if (method_exists($this, 'get_'.$key)) {
228 228
 
229
-			return call_user_func( array( $this, 'get_' . $key ) );
229
+			return call_user_func(array($this, 'get_'.$key));
230 230
 
231 231
 		} else {
232 232
 
233 233
 			/* translators: %s: property key */
234
-			return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
234
+			return new WP_Error('give-customer-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
235 235
 
236 236
 		}
237 237
 
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 	 *
248 248
 	 * @return bool|int    False if not a valid creation, customer ID if user is found or valid creation.
249 249
 	 */
250
-	public function create( $data = array() ) {
250
+	public function create($data = array()) {
251 251
 
252
-		if ( $this->id != 0 || empty( $data ) ) {
252
+		if ($this->id != 0 || empty($data)) {
253 253
 			return false;
254 254
 		}
255 255
 
@@ -257,15 +257,15 @@  discard block
 block discarded – undo
257 257
 			'payment_ids' => '',
258 258
 		);
259 259
 
260
-		$args = wp_parse_args( $data, $defaults );
261
-		$args = $this->sanitize_columns( $args );
260
+		$args = wp_parse_args($data, $defaults);
261
+		$args = $this->sanitize_columns($args);
262 262
 
263
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
263
+		if (empty($args['email']) || ! is_email($args['email'])) {
264 264
 			return false;
265 265
 		}
266 266
 
267
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
268
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
267
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
268
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
269 269
 		}
270 270
 
271 271
 		/**
@@ -275,18 +275,18 @@  discard block
 block discarded – undo
275 275
 		 *
276 276
 		 * @param array $args Customer attributes.
277 277
 		 */
278
-		do_action( 'give_customer_pre_create', $args );
278
+		do_action('give_customer_pre_create', $args);
279 279
 
280 280
 		$created = false;
281 281
 
282 282
 		// The DB class 'add' implies an update if the customer being asked to be created already exists
283
-		if ( $this->db->add( $data ) ) {
283
+		if ($this->db->add($data)) {
284 284
 
285 285
 			// We've successfully added/updated the customer, reset the class vars with the new data
286
-			$customer = $this->db->get_customer_by( 'email', $args['email'] );
286
+			$customer = $this->db->get_customer_by('email', $args['email']);
287 287
 
288 288
 			// Setup the customer data with the values from DB
289
-			$this->setup_customer( $customer );
289
+			$this->setup_customer($customer);
290 290
 
291 291
 			$created = $this->id;
292 292
 		}
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 		 *                          customer ID if user is found or valid creation.
301 301
 		 * @param array    $args    Customer attributes.
302 302
 		 */
303
-		do_action( 'give_customer_post_create', $created, $args );
303
+		do_action('give_customer_post_create', $created, $args);
304 304
 
305 305
 		return $created;
306 306
 
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @return bool        If the update was successful or not.
318 318
 	 */
319
-	public function update( $data = array() ) {
319
+	public function update($data = array()) {
320 320
 
321
-		if ( empty( $data ) ) {
321
+		if (empty($data)) {
322 322
 			return false;
323 323
 		}
324 324
 
325
-		$data = $this->sanitize_columns( $data );
325
+		$data = $this->sanitize_columns($data);
326 326
 
327 327
 		/**
328 328
 		 * Fires before updating customers.
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 		 * @param int   $customer_id Customer id.
333 333
 		 * @param array $data        Customer attributes.
334 334
 		 */
335
-		do_action( 'give_customer_pre_update', $this->id, $data );
335
+		do_action('give_customer_pre_update', $this->id, $data);
336 336
 
337 337
 		$updated = false;
338 338
 
339
-		if ( $this->db->update( $this->id, $data ) ) {
339
+		if ($this->db->update($this->id, $data)) {
340 340
 
341
-			$customer = $this->db->get_customer_by( 'id', $this->id );
342
-			$this->setup_customer( $customer );
341
+			$customer = $this->db->get_customer_by('id', $this->id);
342
+			$this->setup_customer($customer);
343 343
 
344 344
 			$updated = true;
345 345
 		}
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		 * @param int   $customer_id Customer id.
354 354
 		 * @param array $data        Customer attributes.
355 355
 		 */
356
-		do_action( 'give_customer_post_update', $updated, $this->id, $data );
356
+		do_action('give_customer_post_update', $updated, $this->id, $data);
357 357
 
358 358
 		return $updated;
359 359
 	}
@@ -371,27 +371,27 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return bool            If the attachment was successfuly.
373 373
 	 */
374
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
374
+	public function attach_payment($payment_id = 0, $update_stats = true) {
375 375
 
376
-		if ( empty( $payment_id ) ) {
376
+		if (empty($payment_id)) {
377 377
 			return false;
378 378
 		}
379 379
 
380
-		if ( empty( $this->payment_ids ) ) {
380
+		if (empty($this->payment_ids)) {
381 381
 
382 382
 			$new_payment_ids = $payment_id;
383 383
 
384 384
 		} else {
385 385
 
386
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
386
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
387 387
 
388
-			if ( in_array( $payment_id, $payment_ids ) ) {
388
+			if (in_array($payment_id, $payment_ids)) {
389 389
 				$update_stats = false;
390 390
 			}
391 391
 
392 392
 			$payment_ids[] = $payment_id;
393 393
 
394
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
394
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
395 395
 
396 396
 		}
397 397
 
@@ -403,20 +403,20 @@  discard block
 block discarded – undo
403 403
 		 * @param int $payment_id  Payment id.
404 404
 		 * @param int $customer_id Customer id.
405 405
 		 */
406
-		do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id );
406
+		do_action('give_customer_pre_attach_payment', $payment_id, $this->id);
407 407
 
408
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
408
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
409 409
 
410
-		if ( $payment_added ) {
410
+		if ($payment_added) {
411 411
 
412 412
 			$this->payment_ids = $new_payment_ids;
413 413
 
414 414
 			// We added this payment successfully, increment the stats
415
-			if ( $update_stats ) {
416
-				$payment_amount = give_get_payment_amount( $payment_id );
415
+			if ($update_stats) {
416
+				$payment_amount = give_get_payment_amount($payment_id);
417 417
 
418
-				if ( ! empty( $payment_amount ) ) {
419
-					$this->increase_value( $payment_amount );
418
+				if ( ! empty($payment_amount)) {
419
+					$this->increase_value($payment_amount);
420 420
 				}
421 421
 
422 422
 				$this->increase_purchase_count();
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		 * @param int  $payment_id    Payment id.
433 433
 		 * @param int  $customer_id   Customer id.
434 434
 		 */
435
-		do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id );
435
+		do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id);
436 436
 
437 437
 		return $payment_added;
438 438
 	}
@@ -450,33 +450,33 @@  discard block
 block discarded – undo
450 450
 	 *
451 451
 	 * @return boolean               If the removal was successful.
452 452
 	 */
453
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
453
+	public function remove_payment($payment_id = 0, $update_stats = true) {
454 454
 
455
-		if ( empty( $payment_id ) ) {
455
+		if (empty($payment_id)) {
456 456
 			return false;
457 457
 		}
458 458
 
459
-		$payment = new Give_Payment( $payment_id );
459
+		$payment = new Give_Payment($payment_id);
460 460
 
461
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
461
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
462 462
 			$update_stats = false;
463 463
 		}
464 464
 
465 465
 		$new_payment_ids = '';
466 466
 
467
-		if ( ! empty( $this->payment_ids ) ) {
467
+		if ( ! empty($this->payment_ids)) {
468 468
 
469
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
469
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
470 470
 
471
-			$pos = array_search( $payment_id, $payment_ids );
472
-			if ( false === $pos ) {
471
+			$pos = array_search($payment_id, $payment_ids);
472
+			if (false === $pos) {
473 473
 				return false;
474 474
 			}
475 475
 
476
-			unset( $payment_ids[ $pos ] );
477
-			$payment_ids = array_filter( $payment_ids );
476
+			unset($payment_ids[$pos]);
477
+			$payment_ids = array_filter($payment_ids);
478 478
 
479
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
479
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
480 480
 
481 481
 		}
482 482
 
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
 		 * @param int $payment_id  Payment id.
489 489
 		 * @param int $customer_id Customer id.
490 490
 		 */
491
-		do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id );
491
+		do_action('give_customer_pre_remove_payment', $payment_id, $this->id);
492 492
 
493
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
493
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
494 494
 
495
-		if ( $payment_removed ) {
495
+		if ($payment_removed) {
496 496
 
497 497
 			$this->payment_ids = $new_payment_ids;
498 498
 
499
-			if ( $update_stats ) {
499
+			if ($update_stats) {
500 500
 				// We removed this payment successfully, decrement the stats
501
-				$payment_amount = give_get_payment_amount( $payment_id );
501
+				$payment_amount = give_get_payment_amount($payment_id);
502 502
 
503
-				if ( ! empty( $payment_amount ) ) {
504
-					$this->decrease_value( $payment_amount );
503
+				if ( ! empty($payment_amount)) {
504
+					$this->decrease_value($payment_amount);
505 505
 				}
506 506
 
507 507
 				$this->decrease_purchase_count();
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		 * @param int  $payment_id      Payment id.
518 518
 		 * @param int  $customer_id     Customer id.
519 519
 		 */
520
-		do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id );
520
+		do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id);
521 521
 
522 522
 		return $payment_removed;
523 523
 
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @return int        The donation count.
535 535
 	 */
536
-	public function increase_purchase_count( $count = 1 ) {
536
+	public function increase_purchase_count($count = 1) {
537 537
 
538 538
 		// Make sure it's numeric and not negative.
539
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
539
+		if ( ! is_numeric($count) || $count != absint($count)) {
540 540
 			return false;
541 541
 		}
542 542
 
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 		 * @param int $count       The number to increase by.
551 551
 		 * @param int $customer_id Customer id.
552 552
 		 */
553
-		do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id );
553
+		do_action('give_customer_pre_increase_purchase_count', $count, $this->id);
554 554
 
555
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
555
+		if ($this->update(array('purchase_count' => $new_total))) {
556 556
 			$this->purchase_count = $new_total;
557 557
 		}
558 558
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		 * @param int $count          The number increased by.
566 566
 		 * @param int $customer_id    Customer id.
567 567
 		 */
568
-		do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id );
568
+		do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id);
569 569
 
570 570
 		return $this->purchase_count;
571 571
 	}
@@ -580,16 +580,16 @@  discard block
 block discarded – undo
580 580
 	 *
581 581
 	 * @return mixed      If successful, the new count, otherwise false.
582 582
 	 */
583
-	public function decrease_purchase_count( $count = 1 ) {
583
+	public function decrease_purchase_count($count = 1) {
584 584
 
585 585
 		// Make sure it's numeric and not negative
586
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
586
+		if ( ! is_numeric($count) || $count != absint($count)) {
587 587
 			return false;
588 588
 		}
589 589
 
590 590
 		$new_total = (int) $this->purchase_count - (int) $count;
591 591
 
592
-		if ( $new_total < 0 ) {
592
+		if ($new_total < 0) {
593 593
 			$new_total = 0;
594 594
 		}
595 595
 
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
 		 * @param int $count       The number to decrease by.
602 602
 		 * @param int $customer_id Customer id.
603 603
 		 */
604
-		do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id );
604
+		do_action('give_customer_pre_decrease_purchase_count', $count, $this->id);
605 605
 
606
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
606
+		if ($this->update(array('purchase_count' => $new_total))) {
607 607
 			$this->purchase_count = $new_total;
608 608
 		}
609 609
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		 * @param int $count          The number decreased by.
617 617
 		 * @param int $customer_id    Customer id.
618 618
 		 */
619
-		do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id );
619
+		do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id);
620 620
 
621 621
 		return $this->purchase_count;
622 622
 	}
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
 	 *
632 632
 	 * @return mixed        If successful, the new value, otherwise false.
633 633
 	 */
634
-	public function increase_value( $value = 0.00 ) {
634
+	public function increase_value($value = 0.00) {
635 635
 
636
-		$new_value = floatval( $this->purchase_value ) + $value;
636
+		$new_value = floatval($this->purchase_value) + $value;
637 637
 
638 638
 		/**
639 639
 		 * Fires before increasing customer lifetime value.
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 		 * @param float $value       The value to increase by.
644 644
 		 * @param int   $customer_id Customer id.
645 645
 		 */
646
-		do_action( 'give_customer_pre_increase_value', $value, $this->id );
646
+		do_action('give_customer_pre_increase_value', $value, $this->id);
647 647
 
648
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
648
+		if ($this->update(array('purchase_value' => $new_value))) {
649 649
 			$this->purchase_value = $new_value;
650 650
 		}
651 651
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 		 * @param float $value          The value increased by.
659 659
 		 * @param int   $customer_id    Customer id.
660 660
 		 */
661
-		do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id );
661
+		do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id);
662 662
 
663 663
 		return $this->purchase_value;
664 664
 	}
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 	 *
674 674
 	 * @return mixed        If successful, the new value, otherwise false.
675 675
 	 */
676
-	public function decrease_value( $value = 0.00 ) {
676
+	public function decrease_value($value = 0.00) {
677 677
 
678
-		$new_value = floatval( $this->purchase_value ) - $value;
678
+		$new_value = floatval($this->purchase_value) - $value;
679 679
 
680
-		if ( $new_value < 0 ) {
680
+		if ($new_value < 0) {
681 681
 			$new_value = 0.00;
682 682
 		}
683 683
 
@@ -689,9 +689,9 @@  discard block
 block discarded – undo
689 689
 		 * @param float $value       The value to decrease by.
690 690
 		 * @param int   $customer_id Customer id.
691 691
 		 */
692
-		do_action( 'give_customer_pre_decrease_value', $value, $this->id );
692
+		do_action('give_customer_pre_decrease_value', $value, $this->id);
693 693
 
694
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
694
+		if ($this->update(array('purchase_value' => $new_value))) {
695 695
 			$this->purchase_value = $new_value;
696 696
 		}
697 697
 
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		 * @param float $value          The value decreased by.
705 705
 		 * @param int   $customer_id    Customer id.
706 706
 		 */
707
-		do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id );
707
+		do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id);
708 708
 
709 709
 		return $this->purchase_value;
710 710
 	}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	 *
724 724
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
725 725
 	 */
726
-	public function update_donation_value( $curr_amount, $new_amount ) {
726
+	public function update_donation_value($curr_amount, $new_amount) {
727 727
 		/**
728 728
 		 * Payment total difference value can be:
729 729
 		 *  zero   (in case amount not change)
@@ -733,12 +733,12 @@  discard block
 block discarded – undo
733 733
 		$payment_total_diff = $new_amount - $curr_amount;
734 734
 
735 735
 		// We do not need to update donation stat if donation did not change.
736
-		if ( ! $payment_total_diff ) {
736
+		if ( ! $payment_total_diff) {
737 737
 			return false;
738 738
 		}
739 739
 
740
-		if ( $payment_total_diff > 0 ) {
741
-			$this->increase_value( $payment_total_diff );
740
+		if ($payment_total_diff > 0) {
741
+			$this->increase_value($payment_total_diff);
742 742
 		} else {
743 743
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
744 744
 			$this->decrease_value( -$payment_total_diff );
@@ -758,15 +758,15 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @return array       The notes requested.
760 760
 	 */
761
-	public function get_notes( $length = 20, $paged = 1 ) {
761
+	public function get_notes($length = 20, $paged = 1) {
762 762
 
763
-		$length = is_numeric( $length ) ? $length : 20;
764
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
763
+		$length = is_numeric($length) ? $length : 20;
764
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
765 765
 
766 766
 		$all_notes   = $this->get_raw_notes();
767
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
767
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
768 768
 
769
-		$desired_notes = array_slice( $notes_array, $offset, $length );
769
+		$desired_notes = array_slice($notes_array, $offset, $length);
770 770
 
771 771
 		return $desired_notes;
772 772
 
@@ -783,9 +783,9 @@  discard block
 block discarded – undo
783 783
 	public function get_notes_count() {
784 784
 
785 785
 		$all_notes   = $this->get_raw_notes();
786
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
786
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
787 787
 
788
-		return count( $notes_array );
788
+		return count($notes_array);
789 789
 
790 790
 	}
791 791
 
@@ -799,22 +799,22 @@  discard block
 block discarded – undo
799 799
 	 *
800 800
 	 * @return string|boolean The new note if added successfully, false otherwise.
801 801
 	 */
802
-	public function add_note( $note = '' ) {
802
+	public function add_note($note = '') {
803 803
 
804
-		$note = trim( $note );
805
-		if ( empty( $note ) ) {
804
+		$note = trim($note);
805
+		if (empty($note)) {
806 806
 			return false;
807 807
 		}
808 808
 
809 809
 		$notes = $this->get_raw_notes();
810 810
 
811
-		if ( empty( $notes ) ) {
811
+		if (empty($notes)) {
812 812
 			$notes = '';
813 813
 		}
814 814
 
815
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
816
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
817
-		$notes .= "\n\n" . $new_note;
815
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
816
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
817
+		$notes .= "\n\n".$new_note;
818 818
 
819 819
 		/**
820 820
 		 * Fires before customer note added.
@@ -824,11 +824,11 @@  discard block
 block discarded – undo
824 824
 		 * @param string $new_note    New note to add.
825 825
 		 * @param int    $customer_id Customer id.
826 826
 		 */
827
-		do_action( 'give_customer_pre_add_note', $new_note, $this->id );
827
+		do_action('give_customer_pre_add_note', $new_note, $this->id);
828 828
 
829
-		$updated = $this->update( array( 'notes' => $notes ) );
829
+		$updated = $this->update(array('notes' => $notes));
830 830
 
831
-		if ( $updated ) {
831
+		if ($updated) {
832 832
 			$this->notes = $this->get_notes();
833 833
 		}
834 834
 
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 		 * @param string $new_note       New note added.
842 842
 		 * @param int    $customer_id    Customer id.
843 843
 		 */
844
-		do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id );
844
+		do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id);
845 845
 
846 846
 		// Return the formatted note, so we can test, as well as update any displays
847 847
 		return $new_note;
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 	 */
859 859
 	private function get_raw_notes() {
860 860
 
861
-		$all_notes = $this->db->get_column( 'notes', $this->id );
861
+		$all_notes = $this->db->get_column('notes', $this->id);
862 862
 
863 863
 		return $all_notes;
864 864
 
@@ -875,8 +875,8 @@  discard block
 block discarded – undo
875 875
 	 *
876 876
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
877 877
 	 */
878
-	public function get_meta( $meta_key = '', $single = true ) {
879
-		return Give()->customer_meta->get_meta( $this->id, $meta_key, $single );
878
+	public function get_meta($meta_key = '', $single = true) {
879
+		return Give()->customer_meta->get_meta($this->id, $meta_key, $single);
880 880
 	}
881 881
 
882 882
 	/**
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	 *
892 892
 	 * @return bool               False for failure. True for success.
893 893
 	 */
894
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
895
-		return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
894
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
895
+		return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
896 896
 	}
897 897
 
898 898
 	/**
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
 	 *
908 908
 	 * @return bool               False on failure, true if success.
909 909
 	 */
910
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
911
-		return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
910
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
911
+		return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
912 912
 	}
913 913
 
914 914
 	/**
@@ -922,8 +922,8 @@  discard block
 block discarded – undo
922 922
 	 *
923 923
 	 * @return bool               False for failure. True for success.
924 924
 	 */
925
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
926
-		return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value );
925
+	public function delete_meta($meta_key = '', $meta_value = '') {
926
+		return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value);
927 927
 	}
928 928
 
929 929
 	/**
@@ -936,51 +936,51 @@  discard block
 block discarded – undo
936 936
 	 *
937 937
 	 * @return array       The sanitized data, based off column defaults.
938 938
 	 */
939
-	private function sanitize_columns( $data ) {
939
+	private function sanitize_columns($data) {
940 940
 
941 941
 		$columns        = $this->db->get_columns();
942 942
 		$default_values = $this->db->get_column_defaults();
943 943
 
944
-		foreach ( $columns as $key => $type ) {
944
+		foreach ($columns as $key => $type) {
945 945
 
946 946
 			// Only sanitize data that we were provided
947
-			if ( ! array_key_exists( $key, $data ) ) {
947
+			if ( ! array_key_exists($key, $data)) {
948 948
 				continue;
949 949
 			}
950 950
 
951
-			switch ( $type ) {
951
+			switch ($type) {
952 952
 
953 953
 				case '%s':
954
-					if ( 'email' == $key ) {
955
-						$data[ $key ] = sanitize_email( $data[ $key ] );
956
-					} elseif ( 'notes' == $key ) {
957
-						$data[ $key ] = strip_tags( $data[ $key ] );
954
+					if ('email' == $key) {
955
+						$data[$key] = sanitize_email($data[$key]);
956
+					} elseif ('notes' == $key) {
957
+						$data[$key] = strip_tags($data[$key]);
958 958
 					} else {
959
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
959
+						$data[$key] = sanitize_text_field($data[$key]);
960 960
 					}
961 961
 					break;
962 962
 
963 963
 				case '%d':
964
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
965
-						$data[ $key ] = $default_values[ $key ];
964
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
965
+						$data[$key] = $default_values[$key];
966 966
 					} else {
967
-						$data[ $key ] = absint( $data[ $key ] );
967
+						$data[$key] = absint($data[$key]);
968 968
 					}
969 969
 					break;
970 970
 
971 971
 				case '%f':
972 972
 					// Convert what was given to a float
973
-					$value = floatval( $data[ $key ] );
973
+					$value = floatval($data[$key]);
974 974
 
975
-					if ( ! is_float( $value ) ) {
976
-						$data[ $key ] = $default_values[ $key ];
975
+					if ( ! is_float($value)) {
976
+						$data[$key] = $default_values[$key];
977 977
 					} else {
978
-						$data[ $key ] = $value;
978
+						$data[$key] = $value;
979 979
 					}
980 980
 					break;
981 981
 
982 982
 				default:
983
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
983
+					$data[$key] = sanitize_text_field($data[$key]);
984 984
 					break;
985 985
 
986 986
 			}
@@ -1000,33 +1000,33 @@  discard block
 block discarded – undo
1000 1000
 	 *
1001 1001
 	 * @return bool            If the email was added successfully
1002 1002
 	 */
1003
-	public function add_email( $email = '', $primary = false ) {
1004
-		if ( ! is_email( $email ) ) {
1003
+	public function add_email($email = '', $primary = false) {
1004
+		if ( ! is_email($email)) {
1005 1005
 			return false;
1006 1006
 		}
1007
-		$existing = new Give_Customer( $email );
1007
+		$existing = new Give_Customer($email);
1008 1008
 
1009
-		if ( $existing->id > 0 ) {
1009
+		if ($existing->id > 0) {
1010 1010
 			// Email address already belongs to another customer
1011 1011
 			return false;
1012 1012
 		}
1013 1013
 
1014
-		if ( email_exists( $email ) ) {
1015
-			$user = get_user_by( 'email', $email );
1016
-			if ( $user->ID != $this->user_id ) {
1014
+		if (email_exists($email)) {
1015
+			$user = get_user_by('email', $email);
1016
+			if ($user->ID != $this->user_id) {
1017 1017
 				return false;
1018 1018
 			}
1019 1019
 		}
1020 1020
 
1021
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1021
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1022 1022
 
1023 1023
 		// Add is used to ensure duplicate emails are not added
1024
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1024
+		$ret = (bool) $this->add_meta('additional_email', $email);
1025 1025
 
1026
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1026
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1027 1027
 
1028
-		if ( $ret && true === $primary ) {
1029
-			$this->set_primary_email( $email );
1028
+		if ($ret && true === $primary) {
1029
+			$this->set_primary_email($email);
1030 1030
 		}
1031 1031
 
1032 1032
 		return $ret;
@@ -1042,16 +1042,16 @@  discard block
 block discarded – undo
1042 1042
 	 *
1043 1043
 	 * @return bool          If the email was removed 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
 	}
@@ -1068,16 +1068,16 @@  discard block
 block discarded – undo
1068 1068
 	 *
1069 1069
 	 * @return bool                      If the email was set as primary successfully
1070 1070
 	 */
1071
-	public function set_primary_email( $new_primary_email = '' ) {
1072
-		if ( ! is_email( $new_primary_email ) ) {
1071
+	public function set_primary_email($new_primary_email = '') {
1072
+		if ( ! is_email($new_primary_email)) {
1073 1073
 			return false;
1074 1074
 		}
1075 1075
 
1076
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1076
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1077 1077
 
1078
-		$existing = new Give_Customer( $new_primary_email );
1078
+		$existing = new Give_Customer($new_primary_email);
1079 1079
 
1080
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1080
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1081 1081
 			// This email belongs to another customer
1082 1082
 			return false;
1083 1083
 		}
@@ -1085,21 +1085,21 @@  discard block
 block discarded – undo
1085 1085
 		$old_email = $this->email;
1086 1086
 
1087 1087
 		// Update customer record with new email
1088
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1088
+		$update = $this->update(array('email' => $new_primary_email));
1089 1089
 
1090 1090
 		// Remove new primary from list of additional emails
1091
-		$remove = $this->remove_email( $new_primary_email );
1091
+		$remove = $this->remove_email($new_primary_email);
1092 1092
 
1093 1093
 		// Add old email to additional emails list
1094
-		$add = $this->add_email( $old_email );
1094
+		$add = $this->add_email($old_email);
1095 1095
 
1096 1096
 		$ret = $update && $remove && $add;
1097 1097
 
1098
-		if ( $ret ) {
1098
+		if ($ret) {
1099 1099
 			$this->email = $new_primary_email;
1100 1100
 		}
1101 1101
 
1102
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1102
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1103 1103
 
1104 1104
 		return $ret;
1105 1105
 	}
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 1 patch
Spacing   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17
-if ( ! class_exists( 'Give_License' ) ) :
17
+if ( ! class_exists('Give_License')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_License Class
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		 *
104 104
 		 * @var    string
105 105
 		 */
106
-		private $api_url      = 'https://givewp.com/edd-sl-api/';
106
+		private $api_url = 'https://givewp.com/edd-sl-api/';
107 107
 
108 108
 		/**
109 109
 		 * Account URL
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		 *
114 114
 		 * @var null|string
115 115
 		 */
116
-		private $account_url  = 'https://givewp.com/my-account/';
116
+		private $account_url = 'https://givewp.com/my-account/';
117 117
 
118 118
 		/**
119 119
 		 * Ccheckout URL
@@ -142,19 +142,19 @@  discard block
 block discarded – undo
142 142
 		 * @param string  $_checkout_url
143 143
 		 * @param string  $_account_url
144 144
 		 */
145
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) {
145
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) {
146 146
 			$give_options = give_get_settings();
147 147
 
148 148
 			$this->file           = $_file;
149 149
 			$this->item_name      = $_item_name;
150
-			$this->item_shortname = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
150
+			$this->item_shortname = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
151 151
 			$this->version        = $_version;
152
-			$this->license        = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
153
-			$this->license_data   = get_option( $this->item_shortname . '_license_active' );
152
+			$this->license        = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
153
+			$this->license_data   = get_option($this->item_shortname.'_license_active');
154 154
 			$this->author         = $_author;
155
-			$this->api_url        = is_null( $_api_url ) ? $this->api_url : $_api_url;
156
-			$this->checkout_url   = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
157
-			$this->account_url    = is_null( $_account_url ) ? $this->account_url : $_account_url;
155
+			$this->api_url        = is_null($_api_url) ? $this->api_url : $_api_url;
156
+			$this->checkout_url   = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
157
+			$this->account_url    = is_null($_account_url) ? $this->account_url : $_account_url;
158 158
 
159 159
 			// Setup hooks
160 160
 			$this->includes();
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		 * @return void
174 174
 		 */
175 175
 		private function includes() {
176
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
176
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
177 177
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
178 178
 			}
179 179
 		}
@@ -191,26 +191,26 @@  discard block
 block discarded – undo
191 191
 		private function hooks() {
192 192
 
193 193
 			// Register settings
194
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
194
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
195 195
 
196 196
 			// Activate license key on settings save
197
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
197
+			add_action('admin_init', array($this, 'activate_license'));
198 198
 
199 199
 			// Deactivate license key
200
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
200
+			add_action('admin_init', array($this, 'deactivate_license'));
201 201
 
202 202
 			// Updater
203
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
203
+			add_action('admin_init', array($this, 'auto_updater'), 0);
204 204
 
205
-			add_action( 'admin_notices', array( $this, 'notices' ) );
205
+			add_action('admin_notices', array($this, 'notices'));
206 206
 
207 207
 			// Check license weekly.
208
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) );
209
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) );
208
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check'));
209
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check'));
210 210
 
211 211
 			// Check subscription weekly.
212
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) );
213
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) );
212
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check'));
213
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check'));
214 214
 		}
215 215
 
216 216
 		/**
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 		 */
224 224
 		public function auto_updater() {
225 225
 
226
-			if ( ! $this->is_valid_license() ) {
226
+			if ( ! $this->is_valid_license()) {
227 227
 				return false;
228 228
 			}
229 229
 
@@ -252,16 +252,16 @@  discard block
 block discarded – undo
252 252
 		 *
253 253
 		 * @return array           License settings.
254 254
 		 */
255
-		public function settings( $settings ) {
255
+		public function settings($settings) {
256 256
 
257 257
 			$give_license_settings = array(
258 258
 				array(
259 259
 					'name'    => $this->item_name,
260
-					'id'      => $this->item_shortname . '_license_key',
260
+					'id'      => $this->item_shortname.'_license_key',
261 261
 					'desc'    => '',
262 262
 					'type'    => 'license_key',
263 263
 					'options' => array(
264
-						'license'       => get_option( $this->item_shortname . '_license_active' ),
264
+						'license'       => get_option($this->item_shortname.'_license_active'),
265 265
 						'shortname'     => $this->item_shortname,
266 266
 						'item_name'     => $this->item_name,
267 267
 						'api_url'       => $this->api_url,
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 				)
273 273
 			);
274 274
 
275
-			return array_merge( $settings, $give_license_settings );
275
+			return array_merge($settings, $give_license_settings);
276 276
 		}
277 277
 
278 278
 		/**
@@ -287,18 +287,18 @@  discard block
 block discarded – undo
287 287
 		 *
288 288
 		 * @return array           License settings content.
289 289
 		 */
290
-		public function license_settings_content( $settings ) {
290
+		public function license_settings_content($settings) {
291 291
 
292 292
 			$give_license_settings = array(
293 293
 				array(
294
-					'name' => esc_html__( 'Add-on Licenses', 'give' ),
294
+					'name' => esc_html__('Add-on Licenses', 'give'),
295 295
 					'desc' => '<hr>',
296 296
 					'type' => 'give_title',
297 297
 					'id'   => 'give_title'
298 298
 				),
299 299
 			);
300 300
 
301
-			return array_merge( $settings, $give_license_settings );
301
+			return array_merge($settings, $give_license_settings);
302 302
 		}
303 303
 
304 304
 		/**
@@ -313,37 +313,37 @@  discard block
 block discarded – undo
313 313
 		 */
314 314
 		public function activate_license() {
315 315
 			// Bailout: Check if license key set of not.
316
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
316
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
317 317
 				return;
318 318
 			}
319 319
 
320 320
 			// Security check.
321
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
321
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
322 322
 
323
-				wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
323
+				wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
324 324
 
325 325
 			}
326 326
 
327 327
 			// Check if user have correct permissions.
328
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
328
+			if ( ! current_user_can('manage_give_settings')) {
329 329
 				return;
330 330
 			}
331 331
 
332 332
 			// Allow third party addon developers to handle license activation.
333
-			if( $this->__is_third_party_addon() ){
334
-				do_action( 'give_activate_license', $this );
333
+			if ($this->__is_third_party_addon()) {
334
+				do_action('give_activate_license', $this);
335 335
 				return;
336 336
 			}
337 337
 
338 338
 			// Delete previous license setting if a empty license key submitted.
339
-			if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
340
-				delete_option( $this->item_shortname . '_license_active' );
339
+			if (empty($_POST[$this->item_shortname.'_license_key'])) {
340
+				delete_option($this->item_shortname.'_license_active');
341 341
 				return;
342 342
 			}
343 343
 
344 344
 			// Do not simultaneously activate any addon if user want to deactivate any addon.
345
-			foreach ( $_POST as $key => $value ) {
346
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
345
+			foreach ($_POST as $key => $value) {
346
+				if (false !== strpos($key, 'license_key_deactivate')) {
347 347
 					// Don't activate a key when deactivating a different key
348 348
 					return;
349 349
 				}
@@ -351,15 +351,15 @@  discard block
 block discarded – undo
351 351
 
352 352
 
353 353
 			// Check if plugin previously installed.
354
-			if ( $this->is_valid_license() ) {
354
+			if ($this->is_valid_license()) {
355 355
 				return;
356 356
 			}
357 357
 
358 358
 			// Get license key.
359
-			$license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
359
+			$license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
360 360
 
361 361
 			// Bailout.
362
-			if( empty( $license ) ) {
362
+			if (empty($license)) {
363 363
 				return;
364 364
 			}
365 365
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 			$api_params = array(
371 371
 				'edd_action' => 'activate_license', //never change from "edd_" to "give_"!
372 372
 				'license'    => $license,
373
-				'item_name'  => urlencode( $this->item_name ),
373
+				'item_name'  => urlencode($this->item_name),
374 374
 				'url'        => home_url()
375 375
 			);
376 376
 
@@ -385,16 +385,16 @@  discard block
 block discarded – undo
385 385
 			);
386 386
 
387 387
 			// Make sure there are no errors
388
-			if ( is_wp_error( $response ) ) {
388
+			if (is_wp_error($response)) {
389 389
 				return;
390 390
 			}
391 391
 
392 392
 			// Tell WordPress to look for updates
393
-			set_site_transient( 'update_plugins', null );
393
+			set_site_transient('update_plugins', null);
394 394
 
395 395
 			// Decode license data
396
-			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
397
-			update_option( $this->item_shortname . '_license_active', $license_data );
396
+			$license_data = json_decode(wp_remote_retrieve_body($response));
397
+			update_option($this->item_shortname.'_license_active', $license_data);
398 398
 
399 399
 			// Check subscription for license key and store this to db (if any).
400 400
 			$this->__single_subscription_check();
@@ -412,34 +412,34 @@  discard block
 block discarded – undo
412 412
 		 */
413 413
 		public function deactivate_license() {
414 414
 
415
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
415
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
416 416
 				return;
417 417
 			}
418 418
 
419
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
419
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
420 420
 
421
-				wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
421
+				wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
422 422
 
423 423
 			}
424 424
 
425
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
425
+			if ( ! current_user_can('manage_give_settings')) {
426 426
 				return;
427 427
 			}
428 428
 
429 429
 			// Allow third party addon developers to handle license deactivation.
430
-			if( $this->__is_third_party_addon() ){
431
-				do_action( 'give_deactivate_license', $this );
430
+			if ($this->__is_third_party_addon()) {
431
+				do_action('give_deactivate_license', $this);
432 432
 				return;
433 433
 			}
434 434
 
435 435
 			// Run on deactivate button press
436
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
436
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
437 437
 
438 438
 				// Data to send to the API
439 439
 				$api_params = array(
440 440
 					'edd_action' => 'deactivate_license', //never change from "edd_" to "give_"!
441 441
 					'license'    => $this->license,
442
-					'item_name'  => urlencode( $this->item_name ),
442
+					'item_name'  => urlencode($this->item_name),
443 443
 					'url'        => home_url()
444 444
 				);
445 445
 
@@ -454,15 +454,15 @@  discard block
 block discarded – undo
454 454
 				);
455 455
 
456 456
 				// Make sure there are no errors
457
-				if ( is_wp_error( $response ) ) {
457
+				if (is_wp_error($response)) {
458 458
 					return;
459 459
 				}
460 460
 
461 461
 				// Decode the license data
462
-				$license_data = json_decode( wp_remote_retrieve_body( $response ) );
462
+				$license_data = json_decode(wp_remote_retrieve_body($response));
463 463
 
464 464
 				// Remove license data.
465
-				delete_option( $this->item_shortname . '_license_active' );
465
+				delete_option($this->item_shortname.'_license_active');
466 466
 
467 467
 				// Remove license key from subscriptions if exist.
468 468
 				$this->__remove_license_key_from_subscriptions();
@@ -479,18 +479,18 @@  discard block
 block discarded – undo
479 479
 		 */
480 480
 		public function weekly_license_check() {
481 481
 
482
-			if( ! empty( $_POST['give_settings'] ) ) {
482
+			if ( ! empty($_POST['give_settings'])) {
483 483
 				// Don't fire when saving settings
484 484
 				return false;
485 485
 			}
486 486
 
487
-			if( empty( $this->license ) ) {
487
+			if (empty($this->license)) {
488 488
 				return false;
489 489
 			}
490 490
 
491 491
 			// Allow third party addon developers to handle their license check.
492
-			if( $this->__is_third_party_addon() ){
493
-				do_action( 'give_weekly_license_check', $this );
492
+			if ($this->__is_third_party_addon()) {
493
+				do_action('give_weekly_license_check', $this);
494 494
 				return false;
495 495
 			}
496 496
 
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 			$api_params = array(
499 499
 				'edd_action'=> 'check_license',
500 500
 				'license' 	=> $this->license,
501
-				'item_name' => urlencode( $this->item_name ),
501
+				'item_name' => urlencode($this->item_name),
502 502
 				'url'       => home_url()
503 503
 			);
504 504
 
@@ -513,12 +513,12 @@  discard block
 block discarded – undo
513 513
 			);
514 514
 
515 515
 			// Make sure the response came back okay.
516
-			if ( is_wp_error( $response ) ) {
516
+			if (is_wp_error($response)) {
517 517
 				return false;
518 518
 			}
519 519
 
520
-			$license_data = json_decode( wp_remote_retrieve_body( $response ) );
521
-			update_option( $this->item_shortname . '_license_active', $license_data );
520
+			$license_data = json_decode(wp_remote_retrieve_body($response));
521
+			update_option($this->item_shortname.'_license_active', $license_data);
522 522
 		}
523 523
 
524 524
 		/**
@@ -531,24 +531,24 @@  discard block
 block discarded – undo
531 531
 		 */
532 532
 		public function weekly_subscription_check() {
533 533
 
534
-			if( ! empty( $_POST['give_settings'] ) ) {
534
+			if ( ! empty($_POST['give_settings'])) {
535 535
 				// Don't fire when saving settings
536 536
 				return false;
537 537
 			}
538 538
 
539 539
 			// Remove old subscription data.
540
-			if( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp' , 1 ) ){
541
-				delete_option( 'give_subscriptions' );
542
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp' , 1 ) ) );
540
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
541
+				delete_option('give_subscriptions');
542
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
543 543
 			}
544 544
 
545
-			if( empty( $this->license ) ) {
545
+			if (empty($this->license)) {
546 546
 				return false;
547 547
 			}
548 548
 
549 549
 			// Allow third party addon developers to handle there subscription check.
550
-			if( $this->__is_third_party_addon() ){
551
-				do_action( 'give_weekly_subscription_check', $this );
550
+			if ($this->__is_third_party_addon()) {
551
+				do_action('give_weekly_subscription_check', $this);
552 552
 				return false;
553 553
 			}
554 554
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 				// This is custom feature to check subscriptions.
563 563
 				'edd_action'=> 'check_subscription',
564 564
 				'license' 	=> $this->license,
565
-				'item_name' => urlencode( $this->item_name ),
565
+				'item_name' => urlencode($this->item_name),
566 566
 				'url'       => home_url()
567 567
 			);
568 568
 
@@ -577,27 +577,27 @@  discard block
 block discarded – undo
577 577
 			);
578 578
 
579 579
 			// Make sure the response came back okay.
580
-			if ( is_wp_error( $response ) ) {
580
+			if (is_wp_error($response)) {
581 581
 				return false;
582 582
 			}
583 583
 
584
-			$subscription_data = json_decode( wp_remote_retrieve_body( $response ), true );
584
+			$subscription_data = json_decode(wp_remote_retrieve_body($response), true);
585 585
 
586
-			if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
587
-				$subscriptions = get_option( 'give_subscriptions', array() );
586
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
587
+				$subscriptions = get_option('give_subscriptions', array());
588 588
 
589 589
 				// Update subscription data only if subscription does not exist already.
590
-				if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) {
591
-					$subscriptions[ $subscription_data['id'] ] = $subscription_data;
592
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
590
+				if ( ! array_key_exists($subscription_data['id'], $subscriptions)) {
591
+					$subscriptions[$subscription_data['id']] = $subscription_data;
592
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
593 593
 				}
594 594
 
595 595
 				// Store licenses for subscription.
596
-				if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
597
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
596
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
597
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
598 598
 				}
599 599
 
600
-				update_option( 'give_subscriptions', $subscriptions );
600
+				update_option('give_subscriptions', $subscriptions);
601 601
 			}
602 602
 		}
603 603
 
@@ -611,11 +611,11 @@  discard block
 block discarded – undo
611 611
 		 */
612 612
 		private function __single_subscription_check() {
613 613
 			// Do not fire if license key is not set.
614
-			if ( ! isset( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
614
+			if ( ! isset($_POST[$this->item_shortname.'_license_key'])) {
615 615
 				return false;
616 616
 			}
617 617
 
618
-			if( empty( $this->license ) ) {
618
+			if (empty($this->license)) {
619 619
 				return false;
620 620
 			}
621 621
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 				// This is custom feature to check subscriptions.
627 627
 				'edd_action'=> 'check_subscription',
628 628
 				'license' 	=> $this->license,
629
-				'item_name' => urlencode( $this->item_name ),
629
+				'item_name' => urlencode($this->item_name),
630 630
 				'url'       => home_url()
631 631
 			);
632 632
 
@@ -641,27 +641,27 @@  discard block
 block discarded – undo
641 641
 			);
642 642
 
643 643
 			// Make sure the response came back okay.
644
-			if ( is_wp_error( $response ) ) {
644
+			if (is_wp_error($response)) {
645 645
 				return false;
646 646
 			}
647 647
 
648
-			$subscription_data = json_decode( wp_remote_retrieve_body( $response ), true );
648
+			$subscription_data = json_decode(wp_remote_retrieve_body($response), true);
649 649
 
650
-			if( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
651
-				$subscriptions = get_option( 'give_subscriptions', array() );
650
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
651
+				$subscriptions = get_option('give_subscriptions', array());
652 652
 
653 653
 				// Update subscription data only if subscription does not exist already.
654
-				if( ! array_key_exists( $subscription_data['id'], $subscriptions ) ) {
655
-					$subscriptions[ $subscription_data['id'] ] = $subscription_data;
656
-					$subscriptions[ $subscription_data['id'] ]['licenses'] = array();
654
+				if ( ! array_key_exists($subscription_data['id'], $subscriptions)) {
655
+					$subscriptions[$subscription_data['id']] = $subscription_data;
656
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
657 657
 				}
658 658
 
659 659
 				// Store licenses for subscription.
660
-				if( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
661
-					$subscriptions[ $subscription_data['id'] ]['licenses'][] = $this->license;
660
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
661
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
662 662
 				}
663 663
 
664
-				update_option( 'give_subscriptions', $subscriptions );
664
+				update_option('give_subscriptions', $subscriptions);
665 665
 			}
666 666
 		}
667 667
 
@@ -674,12 +674,12 @@  discard block
 block discarded – undo
674 674
 		 * @return void
675 675
 		 */
676 676
 		public function notices() {
677
-			if( ! current_user_can( 'manage_give_settings' ) ) {
677
+			if ( ! current_user_can('manage_give_settings')) {
678 678
 				return;
679 679
 			}
680 680
 
681 681
 			// Do not show licenses notices on license tab.
682
-			if( 'licenses' === give_get_current_setting_tab() ) {
682
+			if ('licenses' === give_get_current_setting_tab()) {
683 683
 				return;
684 684
 			}
685 685
 
@@ -688,89 +688,89 @@  discard block
 block discarded – undo
688 688
 			static $addon_license_key_in_subscriptions;
689 689
 
690 690
 			// Set default value.
691
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
691
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
692 692
 			$messages = array();
693 693
 
694
-			if( empty( $this->license ) && empty( $showed_invalid_message ) ) {
694
+			if (empty($this->license) && empty($showed_invalid_message)) {
695 695
 				$messages['general'] = sprintf(
696
-					__( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
697
-					admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
696
+					__('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
697
+					admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
698 698
 				);
699 699
 				$showed_invalid_message = true;
700 700
 
701 701
 			}
702 702
 
703 703
 			// Get subscriptions.
704
-			$subscriptions = get_option( 'give_subscriptions' );
704
+			$subscriptions = get_option('give_subscriptions');
705 705
 
706 706
 			// Show subscription messages.
707
-			if( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
707
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
708 708
 
709
-				foreach ( $subscriptions as $subscription ) {
709
+				foreach ($subscriptions as $subscription) {
710 710
 					// Subscription expires timestamp.
711
-					$subscription_expires = strtotime( $subscription['expires'] );
711
+					$subscription_expires = strtotime($subscription['expires']);
712 712
 
713 713
 					// Start showing subscriptions message before one week of renewal date.
714
-					if( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
714
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
715 715
 						continue;
716 716
 					}
717 717
 
718 718
 					// Check if subscription message already exist in messages.
719
-					if( array_key_exists( $subscription['id'], $messages ) ) {
719
+					if (array_key_exists($subscription['id'], $messages)) {
720 720
 						continue;
721 721
 					}
722 722
 
723
-					if( ( ! $this->__is_notice_dismissed( $subscription['id'] ) && 'active' !== $subscription['status'] ) ) {
723
+					if (( ! $this->__is_notice_dismissed($subscription['id']) && 'active' !== $subscription['status'])) {
724 724
 
725
-						if( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {// Check if license already expired.
725
+						if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {// Check if license already expired.
726 726
 							$messages[$subscription['id']] = sprintf(
727
-								__( 'You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ),
728
-								urldecode( $subscription['invoice_url'] ),
727
+								__('You Give addon license expired for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'),
728
+								urldecode($subscription['invoice_url']),
729 729
 								$subscription['payment_id'],
730 730
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
731
-								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
731
+								esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI']))
732 732
 							);
733
-						}else{
733
+						} else {
734 734
 							$messages[$subscription['id']] = sprintf(
735
-								__( 'You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give' ),
736
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
737
-								urldecode( $subscription['invoice_url'] ),
735
+								__('You Give addon license will expire in %s for payment <a href="%s" target="_blank">#%d</a>. <a href="%s" target="_blank">Click to renew an existing license</a> or <a href="%s">Click here if already renewed</a>.', 'give'),
736
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
737
+								urldecode($subscription['invoice_url']),
738 738
 								$subscription['payment_id'],
739 739
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
740
-								esc_url( add_query_arg( '_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI'] ) )
740
+								esc_url(add_query_arg('_give_hide_license_notices_permanently', $subscription['id'], $_SERVER['REQUEST_URI']))
741 741
 							);
742 742
 						}
743 743
 					}
744 744
 
745 745
 					// Stop validation for these license keys.
746
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
746
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
747 747
 				}
748 748
 				$showed_subscriptions_message = true;
749 749
 			}
750 750
 
751 751
 			// Show non subscription addon messages.
752
-			if(
753
-				! in_array( $this->license, $addon_license_key_in_subscriptions )
754
-				&& ! $this->__is_notice_dismissed( 'general' )
752
+			if (
753
+				! in_array($this->license, $addon_license_key_in_subscriptions)
754
+				&& ! $this->__is_notice_dismissed('general')
755 755
 				&& ! $this->is_valid_license()
756
-				&& empty( $showed_invalid_message )
756
+				&& empty($showed_invalid_message)
757 757
 			) {
758 758
 
759 759
 				$messages['general'] = sprintf(
760
-					__( 'You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
761
-					admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
760
+					__('You have invalid or expired license keys for Give Addon. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
761
+					admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
762 762
 				);
763 763
 				$showed_invalid_message = true;
764 764
 
765 765
 			}
766 766
 			
767 767
 			// Print messages.
768
-			if( ! empty( $messages ) ) {
769
-				foreach( $messages as $notice_id => $message ) {
768
+			if ( ! empty($messages)) {
769
+				foreach ($messages as $notice_id => $message) {
770 770
 
771 771
 					echo sprintf(
772 772
 						'<div class="notice notice-error is-dismissible give-license-notice" data-dismiss-notice-shortly="%1$s"><p>%2$s</p></div>',
773
-						esc_url( add_query_arg( '_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'] ) ),
773
+						esc_url(add_query_arg('_give_hide_license_notices_shortly', $notice_id, $_SERVER['REQUEST_URI'])),
774 774
 						$message
775 775
 					);
776 776
 				}
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 		 * @return bool
787 787
 		 */
788 788
 		public function is_valid_license() {
789
-			if( apply_filters( 'give_is_valid_license' , ( is_object( $this->license_data ) && ! empty( $this->license_data ) &&  property_exists( $this->license_data, 'license' )&& 'valid' === $this->license_data->license ) ) ) {
789
+			if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) {
790 790
 				return true;
791 791
 			}
792 792
 
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
 		 * @return bool
803 803
 		 */
804 804
 		private function __is_third_party_addon() {
805
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
805
+			return (false === strpos($this->api_url, 'givewp.com/'));
806 806
 		}
807 807
 
808 808
 		/**
@@ -816,26 +816,26 @@  discard block
 block discarded – undo
816 816
 		 *
817 817
 		 * @return void|bool
818 818
 		 */
819
-		private function __remove_license_key_from_subscriptions(){
820
-			$subscriptions = get_option( 'give_subscriptions', array() );
819
+		private function __remove_license_key_from_subscriptions() {
820
+			$subscriptions = get_option('give_subscriptions', array());
821 821
 
822 822
 			// Bailout.
823
-			if( empty( $this->license ) ) {
823
+			if (empty($this->license)) {
824 824
 				return false;
825 825
 			}
826 826
 
827
-			if( ! empty( $subscriptions ) ) {
828
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
829
-					$license_index = array_search( $this->license, $subscription['licenses'] );
830
-					if( false !== $license_index ) {
827
+			if ( ! empty($subscriptions)) {
828
+				foreach ($subscriptions as $subscription_id => $subscription) {
829
+					$license_index = array_search($this->license, $subscription['licenses']);
830
+					if (false !== $license_index) {
831 831
 						// Remove license key.
832
-						unset( $subscriptions[ $subscription_id ]['licenses'][$license_index] );
832
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
833 833
 
834 834
 						// Rearrange license keys.
835
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
835
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
836 836
 
837 837
 						// Update subscription information.
838
-						update_option( 'give_subscriptions', $subscriptions );
838
+						update_option('give_subscriptions', $subscriptions);
839 839
 						break;
840 840
 					}
841 841
 				}
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 		 *
851 851
 		 * @return void
852 852
 		 */
853
-		private function __remove_license_notices_show_blocker(){
853
+		private function __remove_license_notices_show_blocker() {
854 854
 			global $wpdb;
855 855
 
856 856
 			// Delete permanent notice blocker.
@@ -888,18 +888,18 @@  discard block
 block discarded – undo
888 888
 		 *
889 889
 		 * @return bool
890 890
 		 */
891
-		private function __is_notice_dismissed( $notice_id ){
891
+		private function __is_notice_dismissed($notice_id) {
892 892
 			$current_user = wp_get_current_user();
893 893
 			$is_notice_dismissed = false;
894 894
 
895 895
 			// Ge is notice dismissed permanently.
896
-			$already_dismiss_notices = ( $already_dismiss_notices = get_user_meta( $current_user->ID, '_give_hide_license_notices_permanently', true ) )
896
+			$already_dismiss_notices = ($already_dismiss_notices = get_user_meta($current_user->ID, '_give_hide_license_notices_permanently', true))
897 897
 				? $already_dismiss_notices
898 898
 				: array();
899 899
 
900 900
 
901
-			if( in_array( $notice_id, $already_dismiss_notices ) || get_transient( "_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}" ) ) {
902
-				$is_notice_dismissed =  true;
901
+			if (in_array($notice_id, $already_dismiss_notices) || get_transient("_give_hide_license_notices_shortly_{$current_user->ID}_{$notice_id}")) {
902
+				$is_notice_dismissed = true;
903 903
 			}
904 904
 
905 905
 			return $is_notice_dismissed;
Please login to merge, or discard this patch.
includes/admin/customers/customer-actions.php 1 patch
Spacing   +184 added lines, -184 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
 
@@ -53,70 +53,70 @@  discard block
 block discarded – undo
53 53
 		'user_id' => 0,
54 54
 	);
55 55
 
56
-	$customer_info = wp_parse_args( $customer_info, $defaults );
56
+	$customer_info = wp_parse_args($customer_info, $defaults);
57 57
 
58
-	if ( (int) $customer_info['user_id'] != (int) $customer->user_id ) {
58
+	if ((int) $customer_info['user_id'] != (int) $customer->user_id) {
59 59
 
60 60
 		// Make sure we don't already have this user attached to a customer
61
-		if ( ! empty( $customer_info['user_id'] ) && false !== Give()->customers->get_customer_by( 'user_id', $customer_info['user_id'] ) ) {
62
-			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'] ) );
61
+		if ( ! empty($customer_info['user_id']) && false !== Give()->customers->get_customer_by('user_id', $customer_info['user_id'])) {
62
+			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']));
63 63
 		}
64 64
 
65 65
 		// Make sure it's actually a user
66
-		$user = get_user_by( 'id', $customer_info['user_id'] );
67
-		if ( ! empty( $customer_info['user_id'] ) && false === $user ) {
68
-			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'] ) );
66
+		$user = get_user_by('id', $customer_info['user_id']);
67
+		if ( ! empty($customer_info['user_id']) && false === $user) {
68
+			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']));
69 69
 		}
70 70
 	}
71 71
 
72 72
 	// Record this for later
73 73
 	$previous_user_id = $customer->user_id;
74 74
 
75
-	if ( give_get_errors() ) {
75
+	if (give_get_errors()) {
76 76
 		return;
77 77
 	}
78 78
 
79 79
 	// Setup the customer address, if present
80 80
 	$address = array();
81
-	if ( intval( $customer_info['user_id'] ) > 0 ) {
81
+	if (intval($customer_info['user_id']) > 0) {
82 82
 
83
-		$current_address = get_user_meta( $customer_info['user_id'], '_give_user_address', true );
83
+		$current_address = get_user_meta($customer_info['user_id'], '_give_user_address', true);
84 84
 
85
-		if ( false === $current_address ) {
86
-			$address['line1']   = isset( $customer_info['line1'] ) ? $customer_info['line1'] : '';
87
-			$address['line2']   = isset( $customer_info['line2'] ) ? $customer_info['line2'] : '';
88
-			$address['city']    = isset( $customer_info['city'] ) ? $customer_info['city'] : '';
89
-			$address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : '';
90
-			$address['zip']     = isset( $customer_info['zip'] ) ? $customer_info['zip'] : '';
91
-			$address['state']   = isset( $customer_info['state'] ) ? $customer_info['state'] : '';
85
+		if (false === $current_address) {
86
+			$address['line1']   = isset($customer_info['line1']) ? $customer_info['line1'] : '';
87
+			$address['line2']   = isset($customer_info['line2']) ? $customer_info['line2'] : '';
88
+			$address['city']    = isset($customer_info['city']) ? $customer_info['city'] : '';
89
+			$address['country'] = isset($customer_info['country']) ? $customer_info['country'] : '';
90
+			$address['zip']     = isset($customer_info['zip']) ? $customer_info['zip'] : '';
91
+			$address['state']   = isset($customer_info['state']) ? $customer_info['state'] : '';
92 92
 		} else {
93
-			$current_address    = wp_parse_args( $current_address, array(
93
+			$current_address    = wp_parse_args($current_address, array(
94 94
 				'line1',
95 95
 				'line2',
96 96
 				'city',
97 97
 				'zip',
98 98
 				'state',
99 99
 				'country',
100
-			) );
101
-			$address['line1']   = isset( $customer_info['line1'] ) ? $customer_info['line1'] : $current_address['line1'];
102
-			$address['line2']   = isset( $customer_info['line2'] ) ? $customer_info['line2'] : $current_address['line2'];
103
-			$address['city']    = isset( $customer_info['city'] ) ? $customer_info['city'] : $current_address['city'];
104
-			$address['country'] = isset( $customer_info['country'] ) ? $customer_info['country'] : $current_address['country'];
105
-			$address['zip']     = isset( $customer_info['zip'] ) ? $customer_info['zip'] : $current_address['zip'];
106
-			$address['state']   = isset( $customer_info['state'] ) ? $customer_info['state'] : $current_address['state'];
100
+			));
101
+			$address['line1']   = isset($customer_info['line1']) ? $customer_info['line1'] : $current_address['line1'];
102
+			$address['line2']   = isset($customer_info['line2']) ? $customer_info['line2'] : $current_address['line2'];
103
+			$address['city']    = isset($customer_info['city']) ? $customer_info['city'] : $current_address['city'];
104
+			$address['country'] = isset($customer_info['country']) ? $customer_info['country'] : $current_address['country'];
105
+			$address['zip']     = isset($customer_info['zip']) ? $customer_info['zip'] : $current_address['zip'];
106
+			$address['state']   = isset($customer_info['state']) ? $customer_info['state'] : $current_address['state'];
107 107
 		}
108 108
 	}
109 109
 
110 110
 	// Sanitize the inputs
111 111
 	$customer_data            = array();
112
-	$customer_data['name']    = strip_tags( stripslashes( $customer_info['name'] ) );
112
+	$customer_data['name']    = strip_tags(stripslashes($customer_info['name']));
113 113
 	$customer_data['user_id'] = $customer_info['user_id'];
114 114
 
115
-	$customer_data = apply_filters( 'give_edit_customer_info', $customer_data, $customer_id );
116
-	$address       = apply_filters( 'give_edit_customer_address', $address, $customer_id );
115
+	$customer_data = apply_filters('give_edit_customer_info', $customer_data, $customer_id);
116
+	$address       = apply_filters('give_edit_customer_address', $address, $customer_id);
117 117
 
118
-	$customer_data = array_map( 'sanitize_text_field', $customer_data );
119
-	$address       = array_map( 'sanitize_text_field', $address );
118
+	$customer_data = array_map('sanitize_text_field', $customer_data);
119
+	$address       = array_map('sanitize_text_field', $address);
120 120
 
121 121
 	/**
122 122
 	 * Fires before editing customer.
@@ -127,27 +127,27 @@  discard block
 block discarded – undo
127 127
 	 * @param array $customer_data The customer data.
128 128
 	 * @param array $address       The customer address.
129 129
 	 */
130
-	do_action( 'give_pre_edit_customer', $customer_id, $customer_data, $address );
130
+	do_action('give_pre_edit_customer', $customer_id, $customer_data, $address);
131 131
 
132 132
 	$output = array();
133 133
 
134
-	if ( $customer->update( $customer_data ) ) {
134
+	if ($customer->update($customer_data)) {
135 135
 
136
-		if ( ! empty( $customer->user_id ) && $customer->user_id > 0 ) {
137
-			update_user_meta( $customer->user_id, '_give_user_address', $address );
136
+		if ( ! empty($customer->user_id) && $customer->user_id > 0) {
137
+			update_user_meta($customer->user_id, '_give_user_address', $address);
138 138
 		}
139 139
 
140 140
 		// Update some donation meta if we need to
141
-		$payments_array = explode( ',', $customer->payment_ids );
141
+		$payments_array = explode(',', $customer->payment_ids);
142 142
 
143
-		if ( $customer->user_id != $previous_user_id ) {
144
-			foreach ( $payments_array as $payment_id ) {
145
-				give_update_payment_meta( $payment_id, '_give_payment_user_id', $customer->user_id );
143
+		if ($customer->user_id != $previous_user_id) {
144
+			foreach ($payments_array as $payment_id) {
145
+				give_update_payment_meta($payment_id, '_give_payment_user_id', $customer->user_id);
146 146
 			}
147 147
 		}
148 148
 
149 149
 		$output['success']       = true;
150
-		$customer_data           = array_merge( $customer_data, $address );
150
+		$customer_data           = array_merge($customer_data, $address);
151 151
 		$output['customer_info'] = $customer_data;
152 152
 
153 153
 	} else {
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
 	 * @param int   $customer_id   The ID of the customer.
165 165
 	 * @param array $customer_data The customer data.
166 166
 	 */
167
-	do_action( 'give_post_edit_customer', $customer_id, $customer_data );
167
+	do_action('give_post_edit_customer', $customer_id, $customer_data);
168 168
 
169
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
170
-		header( 'Content-Type: application/json' );
171
-		echo json_encode( $output );
169
+	if (defined('DOING_AJAX') && DOING_AJAX) {
170
+		header('Content-Type: application/json');
171
+		echo json_encode($output);
172 172
 		wp_die();
173 173
 	}
174 174
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 }
178 178
 
179
-add_action( 'give_edit-customer', 'give_edit_customer', 10, 1 );
179
+add_action('give_edit-customer', 'give_edit_customer', 10, 1);
180 180
 
181 181
 /**
182 182
  * Save a customer note being added
@@ -187,36 +187,36 @@  discard block
 block discarded – undo
187 187
  *
188 188
  * @return int         The Note ID that was saved, or 0 if nothing was saved
189 189
  */
190
-function give_customer_save_note( $args ) {
190
+function give_customer_save_note($args) {
191 191
 
192
-	$customer_view_role = apply_filters( 'give_view_customers_role', 'view_give_reports' );
192
+	$customer_view_role = apply_filters('give_view_customers_role', 'view_give_reports');
193 193
 
194
-	if ( ! is_admin() || ! current_user_can( $customer_view_role ) ) {
195
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
194
+	if ( ! is_admin() || ! current_user_can($customer_view_role)) {
195
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
196 196
 	}
197 197
 
198
-	if ( empty( $args ) ) {
198
+	if (empty($args)) {
199 199
 		return;
200 200
 	}
201 201
 
202
-	$customer_note = trim( sanitize_text_field( $args['customer_note'] ) );
202
+	$customer_note = trim(sanitize_text_field($args['customer_note']));
203 203
 	$customer_id   = (int) $args['customer_id'];
204 204
 	$nonce         = $args['add_customer_note_nonce'];
205 205
 
206
-	if ( ! wp_verify_nonce( $nonce, 'add-customer-note' ) ) {
207
-		wp_die( esc_html__( 'Cheatin&#8217; uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
206
+	if ( ! wp_verify_nonce($nonce, 'add-customer-note')) {
207
+		wp_die(esc_html__('Cheatin&#8217; uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400));
208 208
 	}
209 209
 
210
-	if ( empty( $customer_note ) ) {
211
-		give_set_error( 'empty-customer-note', esc_html__( 'A note is required.', 'give' ) );
210
+	if (empty($customer_note)) {
211
+		give_set_error('empty-customer-note', esc_html__('A note is required.', 'give'));
212 212
 	}
213 213
 
214
-	if ( give_get_errors() ) {
214
+	if (give_get_errors()) {
215 215
 		return;
216 216
 	}
217 217
 
218
-	$customer = new Give_Customer( $customer_id );
219
-	$new_note = $customer->add_note( $customer_note );
218
+	$customer = new Give_Customer($customer_id);
219
+	$new_note = $customer->add_note($customer_note);
220 220
 
221 221
 	/**
222 222
 	 * Fires before inserting customer note.
@@ -226,22 +226,22 @@  discard block
 block discarded – undo
226 226
 	 * @param int    $customer_id The ID of the customer.
227 227
 	 * @param string $new_note    Note content.
228 228
 	 */
229
-	do_action( 'give_pre_insert_customer_note', $customer_id, $new_note );
229
+	do_action('give_pre_insert_customer_note', $customer_id, $new_note);
230 230
 
231
-	if ( ! empty( $new_note ) && ! empty( $customer->id ) ) {
231
+	if ( ! empty($new_note) && ! empty($customer->id)) {
232 232
 
233 233
 		ob_start();
234 234
 		?>
235 235
 		<div class="customer-note-wrapper dashboard-comment-wrap comment-item">
236 236
 			<span class="note-content-wrap">
237
-				<?php echo stripslashes( $new_note ); ?>
237
+				<?php echo stripslashes($new_note); ?>
238 238
 			</span>
239 239
 		</div>
240 240
 		<?php
241 241
 		$output = ob_get_contents();
242 242
 		ob_end_clean();
243 243
 
244
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
244
+		if (defined('DOING_AJAX') && DOING_AJAX) {
245 245
 			echo $output;
246 246
 			exit;
247 247
 		}
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 
255 255
 }
256 256
 
257
-add_action( 'give_add-customer-note', 'give_customer_save_note', 10, 1 );
257
+add_action('give_add-customer-note', 'give_customer_save_note', 10, 1);
258 258
 
259 259
 /**
260 260
  * Delete a customer
@@ -265,37 +265,37 @@  discard block
 block discarded – undo
265 265
  *
266 266
  * @return int Whether it was a successful deletion
267 267
  */
268
-function give_customer_delete( $args ) {
268
+function give_customer_delete($args) {
269 269
 
270
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
270
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
271 271
 
272
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
273
-		wp_die( esc_html__( 'You do not have permission to delete donors.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
272
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
273
+		wp_die(esc_html__('You do not have permission to delete donors.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
274 274
 	}
275 275
 
276
-	if ( empty( $args ) ) {
276
+	if (empty($args)) {
277 277
 		return;
278 278
 	}
279 279
 
280 280
 	$customer_id = (int) $args['customer_id'];
281
-	$confirm     = ! empty( $args['give-customer-delete-confirm'] ) ? true : false;
282
-	$remove_data = ! empty( $args['give-customer-delete-records'] ) ? true : false;
281
+	$confirm     = ! empty($args['give-customer-delete-confirm']) ? true : false;
282
+	$remove_data = ! empty($args['give-customer-delete-records']) ? true : false;
283 283
 	$nonce       = $args['_wpnonce'];
284 284
 
285
-	if ( ! wp_verify_nonce( $nonce, 'delete-customer' ) ) {
286
-		wp_die( esc_html__( 'Cheatin&#8217; uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
285
+	if ( ! wp_verify_nonce($nonce, 'delete-customer')) {
286
+		wp_die(esc_html__('Cheatin&#8217; uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400));
287 287
 	}
288 288
 
289
-	if ( ! $confirm ) {
290
-		give_set_error( 'customer-delete-no-confirm', esc_html__( 'Please confirm you want to delete this donor.', 'give' ) );
289
+	if ( ! $confirm) {
290
+		give_set_error('customer-delete-no-confirm', esc_html__('Please confirm you want to delete this donor.', 'give'));
291 291
 	}
292 292
 
293
-	if ( give_get_errors() ) {
294
-		wp_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id ) );
293
+	if (give_get_errors()) {
294
+		wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id));
295 295
 		exit;
296 296
 	}
297 297
 
298
-	$customer = new Give_Customer( $customer_id );
298
+	$customer = new Give_Customer($customer_id);
299 299
 
300 300
 	/**
301 301
 	 * Fires before deleting customer.
@@ -306,50 +306,50 @@  discard block
 block discarded – undo
306 306
 	 * @param bool $confirm     Delete confirmation.
307 307
 	 * @param bool $remove_data Records delete confirmation.
308 308
 	 */
309
-	do_action( 'give_pre_delete_customer', $customer_id, $confirm, $remove_data );
309
+	do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data);
310 310
 
311
-	if ( $customer->id > 0 ) {
311
+	if ($customer->id > 0) {
312 312
 
313
-		$payments_array = explode( ',', $customer->payment_ids );
314
-		$success        = Give()->customers->delete( $customer->id );
313
+		$payments_array = explode(',', $customer->payment_ids);
314
+		$success        = Give()->customers->delete($customer->id);
315 315
 
316
-		if ( $success ) {
316
+		if ($success) {
317 317
 
318
-			if ( $remove_data ) {
318
+			if ($remove_data) {
319 319
 
320 320
 				// Remove all donations, logs, etc
321
-				foreach ( $payments_array as $payment_id ) {
322
-					give_delete_purchase( $payment_id );
321
+				foreach ($payments_array as $payment_id) {
322
+					give_delete_purchase($payment_id);
323 323
 				}
324 324
 			} else {
325 325
 
326 326
 				// Just set the donations to customer_id of 0
327
-				foreach ( $payments_array as $payment_id ) {
328
-					give_update_payment_meta( $payment_id, '_give_payment_customer_id', 0 );
327
+				foreach ($payments_array as $payment_id) {
328
+					give_update_payment_meta($payment_id, '_give_payment_customer_id', 0);
329 329
 				}
330 330
 			}
331 331
 
332
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted' );
332
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted');
333 333
 
334 334
 		} else {
335 335
 
336
-			give_set_error( 'give-donor-delete-failed', esc_html__( 'Error deleting donor.', 'give' ) );
337
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id );
336
+			give_set_error('give-donor-delete-failed', esc_html__('Error deleting donor.', 'give'));
337
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$customer_id);
338 338
 
339 339
 		}
340 340
 	} else {
341 341
 
342
-		give_set_error( 'give-customer-delete-invalid-id', esc_html__( 'Invalid Donor ID.', 'give' ) );
343
-		$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors' );
342
+		give_set_error('give-customer-delete-invalid-id', esc_html__('Invalid Donor ID.', 'give'));
343
+		$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors');
344 344
 
345 345
 	}
346 346
 
347
-	wp_redirect( $redirect );
347
+	wp_redirect($redirect);
348 348
 	exit;
349 349
 
350 350
 }
351 351
 
352
-add_action( 'give_delete-customer', 'give_customer_delete', 10, 1 );
352
+add_action('give_delete-customer', 'give_customer_delete', 10, 1);
353 353
 
354 354
 /**
355 355
  * Disconnect a user ID from a donor
@@ -360,27 +360,27 @@  discard block
 block discarded – undo
360 360
  *
361 361
  * @return bool        If the disconnect was successful
362 362
  */
363
-function give_disconnect_customer_user_id( $args ) {
363
+function give_disconnect_customer_user_id($args) {
364 364
 
365
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
365
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
366 366
 
367
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
368
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
367
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
368
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'give'), esc_html__('Error', 'give'), array('response' => 403));
369 369
 	}
370 370
 
371
-	if ( empty( $args ) ) {
371
+	if (empty($args)) {
372 372
 		return;
373 373
 	}
374 374
 
375 375
 	$customer_id = (int) $args['customer_id'];
376 376
 	$nonce       = $args['_wpnonce'];
377 377
 
378
-	if ( ! wp_verify_nonce( $nonce, 'edit-customer' ) ) {
379
-		wp_die( esc_html__( 'Cheatin&#8217; uh?', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) );
378
+	if ( ! wp_verify_nonce($nonce, 'edit-customer')) {
379
+		wp_die(esc_html__('Cheatin&#8217; uh?', 'give'), esc_html__('Error', 'give'), array('response' => 400));
380 380
 	}
381 381
 
382
-	$customer = new Give_Customer( $customer_id );
383
-	if ( empty( $customer->id ) ) {
382
+	$customer = new Give_Customer($customer_id);
383
+	if (empty($customer->id)) {
384 384
 		return false;
385 385
 	}
386 386
 
@@ -394,16 +394,16 @@  discard block
 block discarded – undo
394 394
 	 * @param int $customer_id The ID of the customer.
395 395
 	 * @param int $user_id     The ID of the user.
396 396
 	 */
397
-	do_action( 'give_pre_customer_disconnect_user_id', $customer_id, $user_id );
397
+	do_action('give_pre_customer_disconnect_user_id', $customer_id, $user_id);
398 398
 
399 399
 	$output        = array();
400
-	$customer_args = array( 'user_id' => 0 );
400
+	$customer_args = array('user_id' => 0);
401 401
 
402
-	if ( $customer->update( $customer_args ) ) {
402
+	if ($customer->update($customer_args)) {
403 403
 		global $wpdb;
404 404
 
405
-		if ( ! empty( $customer->payment_ids ) ) {
406
-			$wpdb->query( "UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )" );
405
+		if ( ! empty($customer->payment_ids)) {
406
+			$wpdb->query("UPDATE $wpdb->postmeta SET meta_value = 0 WHERE meta_key = '_give_payment_user_id' AND post_id IN ( $customer->payment_ids )");
407 407
 		}
408 408
 
409 409
 		$output['success'] = true;
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	} else {
412 412
 
413 413
 		$output['success'] = false;
414
-		give_set_error( 'give-disconnect-user-fail', esc_html__( 'Failed to disconnect user from donor.', 'give' ) );
414
+		give_set_error('give-disconnect-user-fail', esc_html__('Failed to disconnect user from donor.', 'give'));
415 415
 	}
416 416
 
417 417
 	/**
@@ -421,11 +421,11 @@  discard block
 block discarded – undo
421 421
 	 *
422 422
 	 * @param int $customer_id The ID of the customer.
423 423
 	 */
424
-	do_action( 'give_post_customer_disconnect_user_id', $customer_id );
424
+	do_action('give_post_customer_disconnect_user_id', $customer_id);
425 425
 
426
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
427
-		header( 'Content-Type: application/json' );
428
-		echo json_encode( $output );
426
+	if (defined('DOING_AJAX') && DOING_AJAX) {
427
+		header('Content-Type: application/json');
428
+		echo json_encode($output);
429 429
 		wp_die();
430 430
 	}
431 431
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 
434 434
 }
435 435
 
436
-add_action( 'give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1 );
436
+add_action('give_disconnect-userid', 'give_disconnect_customer_user_id', 10, 1);
437 437
 
438 438
 /**
439 439
  * Add an email address to the donor from within the admin and log a donor note
@@ -444,82 +444,82 @@  discard block
 block discarded – undo
444 444
  *
445 445
  * @return mixed        If DOING_AJAX echos out JSON, otherwise returns array of success (bool) and message (string)
446 446
  */
447
-function give_add_donor_email( $args ) {
448
-	$customer_edit_role = apply_filters( 'give_edit_customers_role', 'edit_give_payments' );
447
+function give_add_donor_email($args) {
448
+	$customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
449 449
 
450
-	if ( ! is_admin() || ! current_user_can( $customer_edit_role ) ) {
451
-		wp_die( esc_html__( 'You do not have permission to edit this donor.', 'edit' ) );
450
+	if ( ! is_admin() || ! current_user_can($customer_edit_role)) {
451
+		wp_die(esc_html__('You do not have permission to edit this donor.', 'edit'));
452 452
 	}
453 453
 
454 454
 	$output = array();
455
-	if ( empty( $args ) || empty( $args['email'] ) || empty( $args['customer_id'] ) ) {
455
+	if (empty($args) || empty($args['email']) || empty($args['customer_id'])) {
456 456
 		$output['success'] = false;
457
-		if ( empty( $args['email'] ) ) {
458
-			$output['message'] = esc_html__( 'Email address is required.', 'give' );
459
-		} elseif ( empty( $args['customer_id'] ) ) {
460
-			$output['message'] = esc_html__( 'Customer ID is required.', 'give' );
457
+		if (empty($args['email'])) {
458
+			$output['message'] = esc_html__('Email address is required.', 'give');
459
+		} elseif (empty($args['customer_id'])) {
460
+			$output['message'] = esc_html__('Customer ID is required.', 'give');
461 461
 		} else {
462
-			$output['message'] = esc_html__( 'An error has occurred. Please try again.', 'give' );
462
+			$output['message'] = esc_html__('An error has occurred. Please try again.', 'give');
463 463
 		}
464
-	} elseif ( ! wp_verify_nonce( $args['_wpnonce'], 'give_add_donor_email' ) ) {
464
+	} elseif ( ! wp_verify_nonce($args['_wpnonce'], 'give_add_donor_email')) {
465 465
 		$output = array(
466 466
 			'success' => false,
467
-			'message' => esc_html__( 'Nonce verification failed.', 'give' ),
467
+			'message' => esc_html__('Nonce verification failed.', 'give'),
468 468
 		);
469
-	} elseif ( ! is_email( $args['email'] ) ) {
469
+	} elseif ( ! is_email($args['email'])) {
470 470
 		$output = array(
471 471
 			'success' => false,
472
-			'message' => esc_html__( 'Invalid email.', 'give' ),
472
+			'message' => esc_html__('Invalid email.', 'give'),
473 473
 		);
474 474
 	} else {
475
-		$email       = sanitize_email( $args['email'] );
475
+		$email       = sanitize_email($args['email']);
476 476
 		$customer_id = (int) $args['customer_id'];
477 477
 		$primary     = 'true' === $args['primary'] ? true : false;
478
-		$customer    = new Give_Customer( $customer_id );
479
-		if ( false === $customer->add_email( $email, $primary ) ) {
480
-			if ( in_array( $email, $customer->emails ) ) {
478
+		$customer    = new Give_Customer($customer_id);
479
+		if (false === $customer->add_email($email, $primary)) {
480
+			if (in_array($email, $customer->emails)) {
481 481
 				$output = array(
482 482
 					'success' => false,
483
-					'message' => esc_html__( 'Email already associated with this donor.', 'give' ),
483
+					'message' => esc_html__('Email already associated with this donor.', 'give'),
484 484
 				);
485 485
 			} else {
486 486
 				$output = array(
487 487
 					'success' => false,
488
-					'message' => esc_html__( 'Email address is already associated with another donor.', 'give' ),
488
+					'message' => esc_html__('Email address is already associated with another donor.', 'give'),
489 489
 				);
490 490
 			}
491 491
 		} else {
492
-			$redirect = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id . '&give-message=email-added' );
492
+			$redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer_id.'&give-message=email-added');
493 493
 			$output   = array(
494 494
 				'success'  => true,
495
-				'message'  => esc_html__( 'Email successfully added to donor.', 'give' ),
495
+				'message'  => esc_html__('Email successfully added to donor.', 'give'),
496 496
 				'redirect' => $redirect,
497 497
 			);
498 498
 
499 499
 			$user          = wp_get_current_user();
500
-			$user_login    = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' );
501
-			$customer_note = sprintf( __( 'Email address %1$s added by %2$s', 'give' ), $email, $user_login );
502
-			$customer->add_note( $customer_note );
500
+			$user_login    = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give');
501
+			$customer_note = sprintf(__('Email address %1$s added by %2$s', 'give'), $email, $user_login);
502
+			$customer->add_note($customer_note);
503 503
 
504
-			if ( $primary ) {
505
-				$customer_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $email, $user_login );
506
-				$customer->add_note( $customer_note );
504
+			if ($primary) {
505
+				$customer_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $email, $user_login);
506
+				$customer->add_note($customer_note);
507 507
 			}
508 508
 		}
509 509
 	}
510 510
 
511
-	do_action( 'give_post_add_customer_email', $customer_id, $args );
511
+	do_action('give_post_add_customer_email', $customer_id, $args);
512 512
 
513
-	if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
514
-		header( 'Content-Type: application/json' );
515
-		echo json_encode( $output );
513
+	if (defined('DOING_AJAX') && DOING_AJAX) {
514
+		header('Content-Type: application/json');
515
+		echo json_encode($output);
516 516
 		wp_die();
517 517
 	}
518 518
 
519 519
 	return $output;
520 520
 }
521 521
 
522
-add_action( 'give_add_donor_email', 'give_add_donor_email', 10, 1 );
522
+add_action('give_add_donor_email', 'give_add_donor_email', 10, 1);
523 523
 
524 524
 
525 525
 /**
@@ -530,37 +530,37 @@  discard block
 block discarded – undo
530 530
  * @return bool|null
531 531
  */
532 532
 function give_remove_donor_email() {
533
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
533
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
534 534
 		return false;
535 535
 	}
536
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
536
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
537 537
 		return false;
538 538
 	}
539
-	if ( empty( $_GET['_wpnonce'] ) ) {
539
+	if (empty($_GET['_wpnonce'])) {
540 540
 		return false;
541 541
 	}
542 542
 
543 543
 	$nonce = $_GET['_wpnonce'];
544
-	if ( ! wp_verify_nonce( $nonce, 'give-remove-donor-email' ) ) {
545
-		wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
544
+	if ( ! wp_verify_nonce($nonce, 'give-remove-donor-email')) {
545
+		wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array('response' => 403));
546 546
 	}
547 547
 
548
-	$customer = new Give_Customer( $_GET['id'] );
549
-	if ( $customer->remove_email( $_GET['email'] ) ) {
550
-		$url           = add_query_arg( 'give-message', 'email-removed', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id ) );
548
+	$customer = new Give_Customer($_GET['id']);
549
+	if ($customer->remove_email($_GET['email'])) {
550
+		$url           = add_query_arg('give-message', 'email-removed', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$customer->id));
551 551
 		$user          = wp_get_current_user();
552
-		$user_login    = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' );
553
-		$customer_note = sprintf( __( 'Email address %1$s removed by %2$s', 'give' ), $_GET['email'], $user_login );
554
-		$customer->add_note( $customer_note );
552
+		$user_login    = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give');
553
+		$customer_note = sprintf(__('Email address %1$s removed by %2$s', 'give'), $_GET['email'], $user_login);
554
+		$customer->add_note($customer_note);
555 555
 	} else {
556
-		$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 ) );
556
+		$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));
557 557
 	}
558 558
 
559
-	wp_safe_redirect( $url );
559
+	wp_safe_redirect($url);
560 560
 	exit;
561 561
 }
562 562
 
563
-add_action( 'give_remove_donor_email', 'give_remove_donor_email', 10 );
563
+add_action('give_remove_donor_email', 'give_remove_donor_email', 10);
564 564
 
565 565
 
566 566
 /**
@@ -571,39 +571,39 @@  discard block
 block discarded – undo
571 571
  * @return bool|null
572 572
  */
573 573
 function give_set_donor_primary_email() {
574
-	if ( empty( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) {
574
+	if (empty($_GET['id']) || ! is_numeric($_GET['id'])) {
575 575
 		return false;
576 576
 	}
577 577
 
578
-	if ( empty( $_GET['email'] ) || ! is_email( $_GET['email'] ) ) {
578
+	if (empty($_GET['email']) || ! is_email($_GET['email'])) {
579 579
 		return false;
580 580
 	}
581 581
 
582
-	if ( empty( $_GET['_wpnonce'] ) ) {
582
+	if (empty($_GET['_wpnonce'])) {
583 583
 		return false;
584 584
 	}
585 585
 
586 586
 	$nonce = $_GET['_wpnonce'];
587 587
 
588
-	if ( ! wp_verify_nonce( $nonce, 'give-set-donor-primary-email' ) ) {
589
-		wp_die( esc_html__( 'Nonce verification failed', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) );
588
+	if ( ! wp_verify_nonce($nonce, 'give-set-donor-primary-email')) {
589
+		wp_die(esc_html__('Nonce verification failed', 'give'), esc_html__('Error', 'give'), array('response' => 403));
590 590
 	}
591 591
 
592
-	$donor = new Give_Customer( $_GET['id'] );
592
+	$donor = new Give_Customer($_GET['id']);
593 593
 
594
-	if ( $donor->set_primary_email( $_GET['email'] ) ) {
595
-		$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 ) );
594
+	if ($donor->set_primary_email($_GET['email'])) {
595
+		$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));
596 596
 		$user       = wp_get_current_user();
597
-		$user_login = ! empty( $user->user_login ) ? $user->user_login : esc_html__( 'System', 'give' );
598
-		$donor_note = sprintf( __( 'Email address %1$s set as primary by %2$s', 'give' ), $_GET['email'], $user_login );
597
+		$user_login = ! empty($user->user_login) ? $user->user_login : esc_html__('System', 'give');
598
+		$donor_note = sprintf(__('Email address %1$s set as primary by %2$s', 'give'), $_GET['email'], $user_login);
599 599
 
600
-		$donor->add_note( $donor_note );
600
+		$donor->add_note($donor_note);
601 601
 	} else {
602
-		$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 ) );
602
+		$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));
603 603
 	}
604 604
 
605
-	wp_safe_redirect( $url );
605
+	wp_safe_redirect($url);
606 606
 	exit;
607 607
 }
608 608
 
609
-add_action( 'give_set_donor_primary_email', 'give_set_donor_primary_email', 10 );
609
+add_action('give_set_donor_primary_email', 'give_set_donor_primary_email', 10);
Please login to merge, or discard this patch.
includes/admin/shortcodes/class-shortcode-button.php 1 patch
Spacing   +51 added lines, -51 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
 
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
 	 */
34 34
 	public function __construct() {
35 35
 
36
-		if ( is_admin() ) {
37
-			add_filter( 'mce_external_plugins', array( $this, 'mce_external_plugins' ), 15 );
36
+		if (is_admin()) {
37
+			add_filter('mce_external_plugins', array($this, 'mce_external_plugins'), 15);
38 38
 
39
-			add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_assets' ) );
40
-			add_action( 'admin_enqueue_scripts', array( $this, 'admin_localize_scripts' ), 13 );
41
-			add_action( 'media_buttons', array( $this, 'shortcode_button' ) );
39
+			add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_assets'));
40
+			add_action('admin_enqueue_scripts', array($this, 'admin_localize_scripts'), 13);
41
+			add_action('media_buttons', array($this, 'shortcode_button'));
42 42
 		}
43 43
 
44
-		add_action( "wp_ajax_give_shortcode", array( $this, 'shortcode_ajax' ) );
45
-		add_action( "wp_ajax_nopriv_give_shortcode", array( $this, 'shortcode_ajax' ) );
44
+		add_action("wp_ajax_give_shortcode", array($this, 'shortcode_ajax'));
45
+		add_action("wp_ajax_nopriv_give_shortcode", array($this, 'shortcode_ajax'));
46 46
 	}
47 47
 
48 48
 	/**
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @since 1.0
56 56
 	 */
57
-	public function mce_external_plugins( $plugin_array ) {
57
+	public function mce_external_plugins($plugin_array) {
58 58
 
59
-		if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
59
+		if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages')) {
60 60
 			return false;
61 61
 		}
62 62
 
63
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
63
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
64 64
 
65
-		$plugin_array['give_shortcode'] = GIVE_PLUGIN_URL . 'assets/js/admin/tinymce/mce-plugin' . $suffix . '.js';
65
+		$plugin_array['give_shortcode'] = GIVE_PLUGIN_URL.'assets/js/admin/tinymce/mce-plugin'.$suffix.'.js';
66 66
 
67 67
 		return $plugin_array;
68 68
 	}
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 	 */
77 77
 	public function admin_enqueue_assets() {
78 78
 
79
-		$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
79
+		$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
80 80
 
81 81
 		wp_enqueue_script(
82 82
 			'give_shortcode',
83
-			GIVE_PLUGIN_URL . 'assets/js/admin/admin-shortcodes' . $suffix . '.js',
84
-			array( 'jquery' ),
83
+			GIVE_PLUGIN_URL.'assets/js/admin/admin-shortcodes'.$suffix.'.js',
84
+			array('jquery'),
85 85
 			GIVE_VERSION,
86 86
 			true
87 87
 		);
@@ -96,17 +96,17 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function admin_localize_scripts() {
98 98
 
99
-		if ( ! empty( self::$shortcodes ) ) {
99
+		if ( ! empty(self::$shortcodes)) {
100 100
 
101 101
 			$variables = array();
102 102
 
103
-			foreach ( self::$shortcodes as $shortcode => $values ) {
104
-				if ( ! empty( $values['required'] ) ) {
105
-					$variables[ $shortcode ] = $values['required'];
103
+			foreach (self::$shortcodes as $shortcode => $values) {
104
+				if ( ! empty($values['required'])) {
105
+					$variables[$shortcode] = $values['required'];
106 106
 				}
107 107
 			}
108 108
 
109
-			wp_localize_script( 'give_shortcode', 'scShortcodes', $variables );
109
+			wp_localize_script('give_shortcode', 'scShortcodes', $variables);
110 110
 		}
111 111
 	}
112 112
 
@@ -123,37 +123,37 @@  discard block
 block discarded – undo
123 123
 
124 124
 		// If we load wp editor by ajax then $screen will be empty which generate notice if we treat $screen as WP_Screen object.
125 125
 		// For example we are loading wp editor by ajax in repeater field.
126
-		if ( ! ( $screen instanceof WP_Screen ) ) {
126
+		if ( ! ($screen instanceof WP_Screen)) {
127 127
 			return false;
128 128
 		}
129 129
 
130
-		$shortcode_button_pages = apply_filters( 'give_shortcode_button_pages', array(
130
+		$shortcode_button_pages = apply_filters('give_shortcode_button_pages', array(
131 131
 			'post.php',
132 132
 			'page.php',
133 133
 			'post-new.php',
134 134
 			'post-edit.php',
135 135
 			'edit.php',
136 136
 			'edit.php?post_type=page',
137
-		) );
137
+		));
138 138
 
139 139
 		// Only run in admin post/page creation and edit screens
140
-		if ( in_array( $screen->parent_file, $shortcode_button_pages )
141
-		     && apply_filters( 'give_shortcode_button_condition', true )
142
-		     && ! empty( self::$shortcodes )
140
+		if (in_array($screen->parent_file, $shortcode_button_pages)
141
+		     && apply_filters('give_shortcode_button_condition', true)
142
+		     && ! empty(self::$shortcodes)
143 143
 		) {
144 144
 
145 145
 			$shortcodes = array();
146 146
 
147
-			foreach ( self::$shortcodes as $shortcode => $values ) {
147
+			foreach (self::$shortcodes as $shortcode => $values) {
148 148
 
149 149
 				/**
150 150
 				 * Filters the condition for including the current shortcode
151 151
 				 *
152 152
 				 * @since 1.0
153 153
 				 */
154
-				if ( apply_filters( sanitize_title( $shortcode ) . '_condition', true ) ) {
154
+				if (apply_filters(sanitize_title($shortcode).'_condition', true)) {
155 155
 
156
-					$shortcodes[ $shortcode ] = sprintf(
156
+					$shortcodes[$shortcode] = sprintf(
157 157
 						'<div class="sc-shortcode mce-menu-item give-shortcode-item-%1$s" data-shortcode="%2$s">%3$s</div>',
158 158
 						$shortcode,
159 159
 						$shortcode,
@@ -162,37 +162,37 @@  discard block
 block discarded – undo
162 162
 				}
163 163
 			}
164 164
 
165
-			if ( ! empty( $shortcodes ) ) {
165
+			if ( ! empty($shortcodes)) {
166 166
 
167 167
 				// check current WP version
168
-				$img = ( version_compare( get_bloginfo( 'version' ), '3.5', '<' ) )
169
-					? '<img src="' . GIVE_PLUGIN_URL . 'assets/images/give-media.png" />'
170
-					: '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url(' . give_svg_icons( 'give_grey' ) . ');"></span>';
168
+				$img = (version_compare(get_bloginfo('version'), '3.5', '<'))
169
+					? '<img src="'.GIVE_PLUGIN_URL.'assets/images/give-media.png" />'
170
+					: '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url('.give_svg_icons('give_grey').');"></span>';
171 171
 
172
-				reset( $shortcodes );
172
+				reset($shortcodes);
173 173
 
174
-				if ( count( $shortcodes ) == 1 ) {
174
+				if (count($shortcodes) == 1) {
175 175
 
176
-					$shortcode = key( $shortcodes );
176
+					$shortcode = key($shortcodes);
177 177
 
178 178
 					printf(
179 179
 						'<button class="button sc-shortcode" data-shortcode="%s">%s</button>',
180 180
 						$shortcode,
181
-						sprintf( '%s %s %s',
181
+						sprintf('%s %s %s',
182 182
 							$img,
183
-							esc_html__( 'Insert', 'give' ),
184
-							self::$shortcodes[ $shortcode ]['label']
183
+							esc_html__('Insert', 'give'),
184
+							self::$shortcodes[$shortcode]['label']
185 185
 						)
186 186
 					);
187 187
 				} else {
188 188
 					printf(
189
-						'<div class="sc-wrap">' .
190
-						'<button class="button sc-button">%s %s</button>' .
191
-						'<div class="sc-menu mce-menu">%s</div>' .
189
+						'<div class="sc-wrap">'.
190
+						'<button class="button sc-button">%s %s</button>'.
191
+						'<div class="sc-menu mce-menu">%s</div>'.
192 192
 						'</div>',
193 193
 						$img,
194
-						esc_html__( 'Give Shortcodes', 'give' ),
195
-						implode( '', array_values( $shortcodes ) )
194
+						esc_html__('Give Shortcodes', 'give'),
195
+						implode('', array_values($shortcodes))
196 196
 					);
197 197
 				}
198 198
 			}
@@ -208,15 +208,15 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	public function shortcode_ajax() {
210 210
 
211
-		$shortcode = isset( $_POST['shortcode'] ) ? $_POST['shortcode'] : false;
211
+		$shortcode = isset($_POST['shortcode']) ? $_POST['shortcode'] : false;
212 212
 		$response  = false;
213 213
 
214
-		if ( $shortcode && array_key_exists( $shortcode, self::$shortcodes ) ) {
214
+		if ($shortcode && array_key_exists($shortcode, self::$shortcodes)) {
215 215
 
216
-			$data = self::$shortcodes[ $shortcode ];
216
+			$data = self::$shortcodes[$shortcode];
217 217
 
218
-			if ( ! empty( $data['errors'] ) ) {
219
-				$data['btn_okay'] = array( esc_html__( 'Okay', 'give' ) );
218
+			if ( ! empty($data['errors'])) {
219
+				$data['btn_okay'] = array(esc_html__('Okay', 'give'));
220 220
 			}
221 221
 
222 222
 			$response = array(
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
 			);
229 229
 		} else {
230 230
 			// todo: handle error
231
-			error_log( print_r( 'AJAX error!', 1 ) );
231
+			error_log(print_r('AJAX error!', 1));
232 232
 		}
233 233
 
234
-		wp_send_json( $response );
234
+		wp_send_json($response);
235 235
 	}
236 236
 }
237 237
 
Please login to merge, or discard this patch.
includes/admin/payments/class-payments-table.php 1 patch
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
17 17
 // Load WP_List_Table if not loaded.
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -118,15 +118,15 @@  discard block
 block discarded – undo
118 118
 	public function __construct() {
119 119
 
120 120
 		// Set parent defaults.
121
-		parent::__construct( array(
122
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records.
123
-			'plural'   => give_get_forms_label_plural(),      // Plural name of the listed records.
124
-			'ajax'     => false,                              // Does this table support ajax?
125
-		) );
121
+		parent::__construct(array(
122
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records.
123
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records.
124
+			'ajax'     => false, // Does this table support ajax?
125
+		));
126 126
 
127 127
 		$this->get_payment_counts();
128 128
 		$this->process_bulk_action();
129
-		$this->base_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' );
129
+		$this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history');
130 130
 	}
131 131
 
132 132
 	/**
@@ -135,29 +135,29 @@  discard block
 block discarded – undo
135 135
 	 * @return void
136 136
 	 */
137 137
 	public function advanced_filters() {
138
-		$start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null;
139
-		$end_date   = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : null;
140
-		$status     = isset( $_GET['status'] ) ? $_GET['status'] : '';
138
+		$start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null;
139
+		$end_date   = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : null;
140
+		$status     = isset($_GET['status']) ? $_GET['status'] : '';
141 141
 		?>
142 142
         <div id="give-payment-filters">
143 143
 			<span id="give-payment-date-filters">
144 144
 				<label for="start-date"
145
-                       class="give-start-date-label"><?php esc_html_e( 'Start Date:', 'give' ); ?></label>
145
+                       class="give-start-date-label"><?php esc_html_e('Start Date:', 'give'); ?></label>
146 146
 				<input type="text" id="start-date" name="start-date" class="give_datepicker"
147 147
                        value="<?php echo $start_date; ?>" placeholder="mm/dd/yyyy"/>
148
-				<label for="end-date" class="give-end-date-label"><?php esc_html_e( 'End Date:', 'give' ); ?></label>
148
+				<label for="end-date" class="give-end-date-label"><?php esc_html_e('End Date:', 'give'); ?></label>
149 149
 				<input type="text" id="end-date" name="end-date" class="give_datepicker"
150 150
                        value="<?php echo $end_date; ?>" placeholder="mm/dd/yyyy"/>
151
-				<input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Apply', 'give' ); ?>"/>
151
+				<input type="submit" class="button-secondary" value="<?php esc_attr_e('Apply', 'give'); ?>"/>
152 152
 			</span>
153
-			<?php if ( ! empty( $status ) ) : ?>
154
-                <input type="hidden" name="status" value="<?php echo esc_attr( $status ); ?>"/>
153
+			<?php if ( ! empty($status)) : ?>
154
+                <input type="hidden" name="status" value="<?php echo esc_attr($status); ?>"/>
155 155
 			<?php endif; ?>
156
-			<?php if ( ! empty( $start_date ) || ! empty( $end_date ) ) : ?>
157
-                <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history' ); ?>"
158
-                   class="button-secondary"><?php esc_html_e( 'Clear Filter', 'give' ); ?></a>
156
+			<?php if ( ! empty($start_date) || ! empty($end_date)) : ?>
157
+                <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history'); ?>"
158
+                   class="button-secondary"><?php esc_html_e('Clear Filter', 'give'); ?></a>
159 159
 			<?php endif; ?>
160
-			<?php $this->search_box( esc_html__( 'Search', 'give' ), 'give-payments' ); ?>
160
+			<?php $this->search_box(esc_html__('Search', 'give'), 'give-payments'); ?>
161 161
         </div>
162 162
 
163 163
 		<?php
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
 	 *
175 175
 	 * @return void
176 176
 	 */
177
-	public function search_box( $text, $input_id ) {
178
-		if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
177
+	public function search_box($text, $input_id) {
178
+		if (empty($_REQUEST['s']) && ! $this->has_items()) {
179 179
 			return;
180 180
 		}
181 181
 
182
-		$input_id = $input_id . '-search-input';
182
+		$input_id = $input_id.'-search-input';
183 183
 
184
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
185
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
184
+		if ( ! empty($_REQUEST['orderby'])) {
185
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
186 186
 		}
187
-		if ( ! empty( $_REQUEST['order'] ) ) {
188
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
187
+		if ( ! empty($_REQUEST['order'])) {
188
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
189 189
 		}
190 190
 		?>
191 191
         <p class="search-box" role="search">
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
 			 *
198 198
 			 * @since 1.7
199 199
 			 */
200
-			do_action( 'give_payment_history_search' );
200
+			do_action('give_payment_history_search');
201 201
 			?>
202 202
             <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
203 203
             <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/>
204
-			<?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?><br/>
204
+			<?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?><br/>
205 205
         </p>
206 206
 		<?php
207 207
 	}
@@ -215,52 +215,52 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	public function get_views() {
217 217
 
218
-		$current         = isset( $_GET['status'] ) ? $_GET['status'] : '';
219
-		$total_count     = '&nbsp;<span class="count">(' . $this->total_count . ')</span>';
220
-		$complete_count  = '&nbsp;<span class="count">(' . $this->complete_count . ')</span>';
221
-		$cancelled_count = '&nbsp;<span class="count">(' . $this->cancelled_count . ')</span>';
222
-		$pending_count   = '&nbsp;<span class="count">(' . $this->pending_count . ')</span>';
223
-		$refunded_count  = '&nbsp;<span class="count">(' . $this->refunded_count . ')</span>';
224
-		$failed_count    = '&nbsp;<span class="count">(' . $this->failed_count . ')</span>';
225
-		$abandoned_count = '&nbsp;<span class="count">(' . $this->abandoned_count . ')</span>';
226
-		$revoked_count   = '&nbsp;<span class="count">(' . $this->revoked_count . ')</span>';
218
+		$current         = isset($_GET['status']) ? $_GET['status'] : '';
219
+		$total_count     = '&nbsp;<span class="count">('.$this->total_count.')</span>';
220
+		$complete_count  = '&nbsp;<span class="count">('.$this->complete_count.')</span>';
221
+		$cancelled_count = '&nbsp;<span class="count">('.$this->cancelled_count.')</span>';
222
+		$pending_count   = '&nbsp;<span class="count">('.$this->pending_count.')</span>';
223
+		$refunded_count  = '&nbsp;<span class="count">('.$this->refunded_count.')</span>';
224
+		$failed_count    = '&nbsp;<span class="count">('.$this->failed_count.')</span>';
225
+		$abandoned_count = '&nbsp;<span class="count">('.$this->abandoned_count.')</span>';
226
+		$revoked_count   = '&nbsp;<span class="count">('.$this->revoked_count.')</span>';
227 227
 
228 228
 		$views = array(
229
-			'all'       => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array(
229
+			'all'       => sprintf('<a href="%s"%s>%s</a>', remove_query_arg(array(
230 230
 				'status',
231 231
 				'paged',
232
-			) ), $current === 'all' || $current == '' ? ' class="current"' : '', esc_html__( 'All', 'give' ) . $total_count ),
233
-			'publish'   => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
232
+			)), $current === 'all' || $current == '' ? ' class="current"' : '', esc_html__('All', 'give').$total_count),
233
+			'publish'   => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
234 234
 				'status' => 'publish',
235 235
 				'paged'  => false,
236
-			) ) ), $current === 'publish' ? ' class="current"' : '', esc_html__( 'Completed', 'give' ) . $complete_count ),
237
-			'pending'   => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
236
+			))), $current === 'publish' ? ' class="current"' : '', esc_html__('Completed', 'give').$complete_count),
237
+			'pending'   => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
238 238
 				'status' => 'pending',
239 239
 				'paged'  => false,
240
-			) ) ), $current === 'pending' ? ' class="current"' : '', esc_html__( 'Pending', 'give' ) . $pending_count ),
241
-			'refunded'  => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
240
+			))), $current === 'pending' ? ' class="current"' : '', esc_html__('Pending', 'give').$pending_count),
241
+			'refunded'  => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
242 242
 				'status' => 'refunded',
243 243
 				'paged'  => false,
244
-			) ) ), $current === 'refunded' ? ' class="current"' : '', esc_html__( 'Refunded', 'give' ) . $refunded_count ),
245
-			'revoked'   => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
244
+			))), $current === 'refunded' ? ' class="current"' : '', esc_html__('Refunded', 'give').$refunded_count),
245
+			'revoked'   => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
246 246
 				'status' => 'revoked',
247 247
 				'paged'  => false,
248
-			) ) ), $current === 'revoked' ? ' class="current"' : '', esc_html__( 'Revoked', 'give' ) . $revoked_count ),
249
-			'failed'    => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
248
+			))), $current === 'revoked' ? ' class="current"' : '', esc_html__('Revoked', 'give').$revoked_count),
249
+			'failed'    => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
250 250
 				'status' => 'failed',
251 251
 				'paged'  => false,
252
-			) ) ), $current === 'failed' ? ' class="current"' : '', esc_html__( 'Failed', 'give' ) . $failed_count ),
253
-			'cancelled' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
252
+			))), $current === 'failed' ? ' class="current"' : '', esc_html__('Failed', 'give').$failed_count),
253
+			'cancelled' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
254 254
 				'status' => 'cancelled',
255 255
 				'paged'  => false,
256
-			) ) ), $current === 'cancelled' ? ' class="current"' : '', esc_html__( 'Cancelled', 'give' ) . $cancelled_count ),
257
-			'abandoned' => sprintf( '<a href="%s"%s>%s</a>', esc_url( add_query_arg( array(
256
+			))), $current === 'cancelled' ? ' class="current"' : '', esc_html__('Cancelled', 'give').$cancelled_count),
257
+			'abandoned' => sprintf('<a href="%s"%s>%s</a>', esc_url(add_query_arg(array(
258 258
 				'status' => 'abandoned',
259 259
 				'paged'  => false,
260
-			) ) ), $current === 'abandoned' ? ' class="current"' : '', esc_html__( 'Abandoned', 'give' ) . $abandoned_count ),
260
+			))), $current === 'abandoned' ? ' class="current"' : '', esc_html__('Abandoned', 'give').$abandoned_count),
261 261
 		);
262 262
 
263
-		return apply_filters( 'give_payments_table_views', $views );
263
+		return apply_filters('give_payments_table_views', $views);
264 264
 	}
265 265
 
266 266
 	/**
@@ -273,15 +273,15 @@  discard block
 block discarded – undo
273 273
 	public function get_columns() {
274 274
 		$columns = array(
275 275
 			'cb'            => '<input type="checkbox" />', // Render a checkbox instead of text.
276
-			'donation'      => esc_html__( 'Donation', 'give' ),
277
-			'donation_form' => esc_html__( 'Donation Form', 'give' ),
278
-			'status'        => esc_html__( 'Status', 'give' ),
279
-			'date'          => esc_html__( 'Date', 'give' ),
280
-			'amount'        => esc_html__( 'Amount', 'give' ),
281
-			'details'       => esc_html__( 'Details', 'give' ),
276
+			'donation'      => esc_html__('Donation', 'give'),
277
+			'donation_form' => esc_html__('Donation Form', 'give'),
278
+			'status'        => esc_html__('Status', 'give'),
279
+			'date'          => esc_html__('Date', 'give'),
280
+			'amount'        => esc_html__('Amount', 'give'),
281
+			'details'       => esc_html__('Details', 'give'),
282 282
 		);
283 283
 
284
-		return apply_filters( 'give_payments_table_columns', $columns );
284
+		return apply_filters('give_payments_table_columns', $columns);
285 285
 	}
286 286
 
287 287
 	/**
@@ -293,14 +293,14 @@  discard block
 block discarded – undo
293 293
 	 */
294 294
 	public function get_sortable_columns() {
295 295
 		$columns = array(
296
-			'donation'      => array( 'ID', true ),
297
-			'donation_form' => array( 'donation_form', false ),
298
-			'status'        => array( 'status', false ),
299
-			'amount'        => array( 'amount', false ),
300
-			'date'          => array( 'date', false ),
296
+			'donation'      => array('ID', true),
297
+			'donation_form' => array('donation_form', false),
298
+			'status'        => array('status', false),
299
+			'amount'        => array('amount', false),
300
+			'date'          => array('date', false),
301 301
 		);
302 302
 
303
-		return apply_filters( 'give_payments_table_sortable_columns', $columns );
303
+		return apply_filters('give_payments_table_sortable_columns', $columns);
304 304
 	}
305 305
 
306 306
 	/**
@@ -326,65 +326,65 @@  discard block
 block discarded – undo
326 326
 	 *
327 327
 	 * @return string Column Name
328 328
 	 */
329
-	public function column_default( $payment, $column_name ) {
329
+	public function column_default($payment, $column_name) {
330 330
 
331
-		$single_donation_url = esc_url( add_query_arg( 'id', $payment->ID, admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details' ) ) );
332
-		$row_actions         = $this->get_row_actions( $payment );
331
+		$single_donation_url = esc_url(add_query_arg('id', $payment->ID, admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details')));
332
+		$row_actions         = $this->get_row_actions($payment);
333 333
 
334
-		switch ( $column_name ) {
334
+		switch ($column_name) {
335 335
 			case 'donation' :
336 336
 				$value = sprintf(
337 337
 					'<a href="%1$s" data-tooltip="%2$s">#%3$s</a>&nbsp;%4$s&nbsp;%5$s<br>',
338 338
 					$single_donation_url,
339
-					sprintf( esc_attr__( 'View Donation %s', 'give' ), $payment->ID ),
339
+					sprintf(esc_attr__('View Donation %s', 'give'), $payment->ID),
340 340
 					$payment->ID,
341
-					esc_html__( 'by', 'give' ),
342
-					$this->get_donor( $payment )
341
+					esc_html__('by', 'give'),
342
+					$this->get_donor($payment)
343 343
 				);
344
-				$value .= $this->get_donor_email( $payment );
345
-				$value .= $this->row_actions( $row_actions );
344
+				$value .= $this->get_donor_email($payment);
345
+				$value .= $this->row_actions($row_actions);
346 346
 				break;
347 347
 
348 348
 			case 'amount' :
349
-				$amount = ! empty( $payment->total ) ? $payment->total : 0;
350
-				$value  = give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment->ID ) );
349
+				$amount = ! empty($payment->total) ? $payment->total : 0;
350
+				$value  = give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment->ID));
351 351
 				break;
352 352
 
353 353
 			case 'donation_form' :
354
-				$form_title = empty( $payment->form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $payment->form_id ) : $payment->form_title;
355
-				$value      = '<a href="' . admin_url( 'post.php?post=' . $payment->form_id . '&action=edit' ) . '">' . $form_title . '</a>';
356
-				$level      = give_get_payment_form_title( $payment->meta, true );
354
+				$form_title = empty($payment->form_title) ? sprintf(__('Untitled (#%s)', 'give'), $payment->form_id) : $payment->form_title;
355
+				$value      = '<a href="'.admin_url('post.php?post='.$payment->form_id.'&action=edit').'">'.$form_title.'</a>';
356
+				$level      = give_get_payment_form_title($payment->meta, true);
357 357
 
358
-				if ( ! empty( $level ) ) {
358
+				if ( ! empty($level)) {
359 359
 					$value .= $level;
360 360
 				}
361 361
 
362 362
 				break;
363 363
 
364 364
 			case 'date' :
365
-				$date  = strtotime( $payment->date );
366
-				$value = date_i18n( give_date_format(), $date );
365
+				$date  = strtotime($payment->date);
366
+				$value = date_i18n(give_date_format(), $date);
367 367
 				break;
368 368
 
369 369
 			case 'status' :
370
-				$value = $this->get_payment_status( $payment );
370
+				$value = $this->get_payment_status($payment);
371 371
 				break;
372 372
 
373 373
 			case 'details' :
374 374
 				$value = sprintf(
375 375
 					'<div class="give-payment-details-link-wrap"><a href="%1$s" class="give-payment-details-link button button-small" data-tooltip="%2$s" aria-label="%2$s"><span class="dashicons dashicons-visibility"></span></a></div>',
376 376
 					$single_donation_url,
377
-					sprintf( esc_attr__( 'View Donation %s', 'give' ), $payment->ID )
377
+					sprintf(esc_attr__('View Donation %s', 'give'), $payment->ID)
378 378
 				);
379 379
 				break;
380 380
 
381 381
 			default:
382
-				$value = isset( $payment->$column_name ) ? $payment->$column_name : '';
382
+				$value = isset($payment->$column_name) ? $payment->$column_name : '';
383 383
 				break;
384 384
 
385 385
 		}
386 386
 
387
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, $column_name );
387
+		return apply_filters('give_payments_table_column', $value, $payment->ID, $column_name);
388 388
 	}
389 389
 
390 390
 	/**
@@ -397,17 +397,17 @@  discard block
 block discarded – undo
397 397
 	 *
398 398
 	 * @return string                Data shown in the Email column
399 399
 	 */
400
-	public function get_donor_email( $payment ) {
400
+	public function get_donor_email($payment) {
401 401
 
402
-		$email = give_get_payment_user_email( $payment->ID );
402
+		$email = give_get_payment_user_email($payment->ID);
403 403
 
404
-		if ( empty( $email ) ) {
405
-			$email = esc_html__( '(unknown)', 'give' );
404
+		if (empty($email)) {
405
+			$email = esc_html__('(unknown)', 'give');
406 406
 		}
407 407
 
408
-		$value = '<a href="mailto:' . $email . '" data-tooltip="' . esc_attr__( 'Email donor', 'give' ) . '">' . $email . '</a>';
408
+		$value = '<a href="mailto:'.$email.'" data-tooltip="'.esc_attr__('Email donor', 'give').'">'.$email.'</a>';
409 409
 
410
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'email' );
410
+		return apply_filters('give_payments_table_column', $value, $payment->ID, 'email');
411 411
 	}
412 412
 
413 413
 	/**
@@ -419,18 +419,18 @@  discard block
 block discarded – undo
419 419
 	 *
420 420
 	 * @return array $actions
421 421
 	 */
422
-	function get_row_actions( $payment ) {
422
+	function get_row_actions($payment) {
423 423
 
424 424
 		$actions = array();
425
-		$email   = give_get_payment_user_email( $payment->ID );
425
+		$email   = give_get_payment_user_email($payment->ID);
426 426
 
427 427
 		// Add search term string back to base URL.
428
-		$search_terms = ( isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '' );
429
-		if ( ! empty( $search_terms ) ) {
430
-			$this->base_url = add_query_arg( 's', $search_terms, $this->base_url );
428
+		$search_terms = (isset($_GET['s']) ? trim($_GET['s']) : '');
429
+		if ( ! empty($search_terms)) {
430
+			$this->base_url = add_query_arg('s', $search_terms, $this->base_url);
431 431
 		}
432 432
 
433
-		if ( give_is_payment_complete( $payment->ID ) && ! empty( $email ) ) {
433
+		if (give_is_payment_complete($payment->ID) && ! empty($email)) {
434 434
 
435 435
 			$actions['email_links'] = sprintf(
436 436
 				'<a href="%1$s" aria-label="%2$s">%3$s</a>',
@@ -444,8 +444,8 @@  discard block
 block discarded – undo
444 444
 					),
445 445
 					'give_payment_nonce'
446 446
 				),
447
-				sprintf( esc_attr__( 'Resend Donation %s Receipt', 'give' ), $payment->ID ),
448
-				esc_html__( 'Resend Receipt', 'give' )
447
+				sprintf(esc_attr__('Resend Donation %s Receipt', 'give'), $payment->ID),
448
+				esc_html__('Resend Receipt', 'give')
449 449
 			);
450 450
 
451 451
 		}
@@ -462,11 +462,11 @@  discard block
 block discarded – undo
462 462
 				),
463 463
 				'give_donation_nonce'
464 464
 			),
465
-			sprintf( esc_attr__( 'Delete Donation %s', 'give' ), $payment->ID ),
466
-			esc_html__( 'Delete', 'give' )
465
+			sprintf(esc_attr__('Delete Donation %s', 'give'), $payment->ID),
466
+			esc_html__('Delete', 'give')
467 467
 		);
468 468
 
469
-		return apply_filters( 'give_payment_row_actions', $actions, $payment );
469
+		return apply_filters('give_payment_row_actions', $actions, $payment);
470 470
 	}
471 471
 
472 472
 
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
 	 *
481 481
 	 * @return string                Data shown in the Email column
482 482
 	 */
483
-	function get_payment_status( $payment ) {
484
-		$value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>';
485
-		if ( $payment->mode == 'test' ) {
486
-			$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>';
483
+	function get_payment_status($payment) {
484
+		$value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>';
485
+		if ($payment->mode == 'test') {
486
+			$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.esc_html__('Test', 'give').'</span>';
487 487
 		}
488 488
 
489 489
 		return $value;
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 	 *
500 500
 	 * @return string Displays a checkbox.
501 501
 	 */
502
-	public function column_cb( $payment ) {
502
+	public function column_cb($payment) {
503 503
 		return sprintf(
504 504
 			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
505 505
 			'payment',
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 	 *
518 518
 	 * @return string Displays a checkbox.
519 519
 	 */
520
-	public function get_payment_id( $payment ) {
521
-		return '<span class="give-payment-id">' . give_get_payment_number( $payment->ID ) . '</span>';
520
+	public function get_payment_id($payment) {
521
+		return '<span class="give-payment-id">'.give_get_payment_number($payment->ID).'</span>';
522 522
 	}
523 523
 
524 524
 	/**
@@ -531,19 +531,19 @@  discard block
 block discarded – undo
531 531
 	 *
532 532
 	 * @return string Data shown in the User column
533 533
 	 */
534
-	public function get_donor( $payment ) {
534
+	public function get_donor($payment) {
535 535
 
536
-		$customer_id = give_get_payment_customer_id( $payment->ID );
536
+		$customer_id = give_get_payment_customer_id($payment->ID);
537 537
 
538
-		if ( ! empty( $customer_id ) ) {
539
-			$customer = new Give_Customer( $customer_id );
540
-			$value    = '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-donors&view=overview&id=$customer_id" ) ) . '">' . $customer->name . '</a>';
538
+		if ( ! empty($customer_id)) {
539
+			$customer = new Give_Customer($customer_id);
540
+			$value    = '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-donors&view=overview&id=$customer_id")).'">'.$customer->name.'</a>';
541 541
 		} else {
542
-			$email = give_get_payment_user_email( $payment->ID );
543
-			$value = '<a href="' . esc_url( admin_url( "edit.php?post_type=give_forms&page=give-payment-history&s=$email" ) ) . '">' . esc_html__( '(donor missing)', 'give' ) . '</a>';
542
+			$email = give_get_payment_user_email($payment->ID);
543
+			$value = '<a href="'.esc_url(admin_url("edit.php?post_type=give_forms&page=give-payment-history&s=$email")).'">'.esc_html__('(donor missing)', 'give').'</a>';
544 544
 		}
545 545
 
546
-		return apply_filters( 'give_payments_table_column', $value, $payment->ID, 'donor' );
546
+		return apply_filters('give_payments_table_column', $value, $payment->ID, 'donor');
547 547
 	}
548 548
 
549 549
 	/**
@@ -555,18 +555,18 @@  discard block
 block discarded – undo
555 555
 	 */
556 556
 	public function get_bulk_actions() {
557 557
 		$actions = array(
558
-			'delete'               => esc_html__( 'Delete', 'give' ),
559
-			'set-status-publish'   => esc_html__( 'Set To Completed', 'give' ),
560
-			'set-status-pending'   => esc_html__( 'Set To Pending', 'give' ),
561
-			'set-status-refunded'  => esc_html__( 'Set To Refunded', 'give' ),
562
-			'set-status-revoked'   => esc_html__( 'Set To Revoked', 'give' ),
563
-			'set-status-failed'    => esc_html__( 'Set To Failed', 'give' ),
564
-			'set-status-cancelled' => esc_html__( 'Set To Cancelled', 'give' ),
565
-			'set-status-abandoned' => esc_html__( 'Set To Abandoned', 'give' ),
566
-			'resend-receipt'       => esc_html__( 'Resend Email Receipts', 'give' ),
558
+			'delete'               => esc_html__('Delete', 'give'),
559
+			'set-status-publish'   => esc_html__('Set To Completed', 'give'),
560
+			'set-status-pending'   => esc_html__('Set To Pending', 'give'),
561
+			'set-status-refunded'  => esc_html__('Set To Refunded', 'give'),
562
+			'set-status-revoked'   => esc_html__('Set To Revoked', 'give'),
563
+			'set-status-failed'    => esc_html__('Set To Failed', 'give'),
564
+			'set-status-cancelled' => esc_html__('Set To Cancelled', 'give'),
565
+			'set-status-abandoned' => esc_html__('Set To Abandoned', 'give'),
566
+			'resend-receipt'       => esc_html__('Resend Email Receipts', 'give'),
567 567
 		);
568 568
 
569
-		return apply_filters( 'give_payments_table_bulk_actions', $actions );
569
+		return apply_filters('give_payments_table_bulk_actions', $actions);
570 570
 	}
571 571
 
572 572
 	/**
@@ -577,59 +577,59 @@  discard block
 block discarded – undo
577 577
 	 * @return void
578 578
 	 */
579 579
 	public function process_bulk_action() {
580
-		$ids    = isset( $_GET['payment'] ) ? $_GET['payment'] : false;
580
+		$ids    = isset($_GET['payment']) ? $_GET['payment'] : false;
581 581
 		$action = $this->current_action();
582 582
 
583
-		if ( ! is_array( $ids ) ) {
584
-			$ids = array( $ids );
583
+		if ( ! is_array($ids)) {
584
+			$ids = array($ids);
585 585
 		}
586 586
 
587
-		if ( empty( $action ) ) {
587
+		if (empty($action)) {
588 588
 			return;
589 589
 		}
590 590
 
591
-		foreach ( $ids as $id ) {
591
+		foreach ($ids as $id) {
592 592
 
593 593
 			// Detect when a bulk action is being triggered.
594
-			switch ( $this->current_action() ) {
594
+			switch ($this->current_action()) {
595 595
 
596 596
 				case'delete':
597
-					give_delete_purchase( $id );
597
+					give_delete_purchase($id);
598 598
 					break;
599 599
 
600 600
 				case 'set-status-publish':
601
-					give_update_payment_status( $id, 'publish' );
601
+					give_update_payment_status($id, 'publish');
602 602
 					break;
603 603
 
604 604
 				case 'set-status-pending':
605
-					give_update_payment_status( $id, 'pending' );
605
+					give_update_payment_status($id, 'pending');
606 606
 					break;
607 607
 
608 608
 				case 'set-status-refunded':
609
-					give_update_payment_status( $id, 'refunded' );
609
+					give_update_payment_status($id, 'refunded');
610 610
 					break;
611 611
 				case 'set-status-revoked':
612
-					give_update_payment_status( $id, 'revoked' );
612
+					give_update_payment_status($id, 'revoked');
613 613
 					break;
614 614
 
615 615
 				case 'set-status-failed':
616
-					give_update_payment_status( $id, 'failed' );
616
+					give_update_payment_status($id, 'failed');
617 617
 					break;
618 618
 
619 619
 				case 'set-status-cancelled':
620
-					give_update_payment_status( $id, 'cancelled' );
620
+					give_update_payment_status($id, 'cancelled');
621 621
 					break;
622 622
 
623 623
 				case 'set-status-abandoned':
624
-					give_update_payment_status( $id, 'abandoned' );
624
+					give_update_payment_status($id, 'abandoned');
625 625
 					break;
626 626
 
627 627
 				case 'set-status-preapproval':
628
-					give_update_payment_status( $id, 'preapproval' );
628
+					give_update_payment_status($id, 'preapproval');
629 629
 					break;
630 630
 
631 631
 				case 'resend-receipt':
632
-					give_email_donation_receipt( $id, false );
632
+					give_email_donation_receipt($id, false);
633 633
 					break;
634 634
 			}
635 635
 
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 			 * @param int    $id             The ID of the payment.
642 642
 			 * @param string $current_action The action that is being triggered.
643 643
 			 */
644
-			do_action( 'give_payments_table_do_bulk_action', $id, $this->current_action() );
644
+			do_action('give_payments_table_do_bulk_action', $id, $this->current_action());
645 645
 		}
646 646
 
647 647
 	}
@@ -657,27 +657,27 @@  discard block
 block discarded – undo
657 657
 
658 658
 		$args = array();
659 659
 
660
-		if ( isset( $_GET['user'] ) ) {
661
-			$args['user'] = urldecode( $_GET['user'] );
662
-		} elseif ( isset( $_GET['s'] ) ) {
663
-			$is_user = strpos( $_GET['s'], strtolower( 'user:' ) ) !== false;
664
-			if ( $is_user ) {
665
-				$args['user'] = absint( trim( str_replace( 'user:', '', strtolower( $_GET['s'] ) ) ) );
666
-				unset( $args['s'] );
660
+		if (isset($_GET['user'])) {
661
+			$args['user'] = urldecode($_GET['user']);
662
+		} elseif (isset($_GET['s'])) {
663
+			$is_user = strpos($_GET['s'], strtolower('user:')) !== false;
664
+			if ($is_user) {
665
+				$args['user'] = absint(trim(str_replace('user:', '', strtolower($_GET['s']))));
666
+				unset($args['s']);
667 667
 			} else {
668
-				$args['s'] = sanitize_text_field( $_GET['s'] );
668
+				$args['s'] = sanitize_text_field($_GET['s']);
669 669
 			}
670 670
 		}
671 671
 
672
-		if ( ! empty( $_GET['start-date'] ) ) {
673
-			$args['start-date'] = urldecode( $_GET['start-date'] );
672
+		if ( ! empty($_GET['start-date'])) {
673
+			$args['start-date'] = urldecode($_GET['start-date']);
674 674
 		}
675 675
 
676
-		if ( ! empty( $_GET['end-date'] ) ) {
677
-			$args['end-date'] = urldecode( $_GET['end-date'] );
676
+		if ( ! empty($_GET['end-date'])) {
677
+			$args['end-date'] = urldecode($_GET['end-date']);
678 678
 		}
679 679
 
680
-		$payment_count         = give_count_payments( $args );
680
+		$payment_count         = give_count_payments($args);
681 681
 		$this->complete_count  = $payment_count->publish;
682 682
 		$this->pending_count   = $payment_count->pending;
683 683
 		$this->refunded_count  = $payment_count->refunded;
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 		$this->cancelled_count = $payment_count->cancelled;
687 687
 		$this->abandoned_count = $payment_count->abandoned;
688 688
 
689
-		foreach ( $payment_count as $count ) {
689
+		foreach ($payment_count as $count) {
690 690
 			$this->total_count += $count;
691 691
 		}
692 692
 	}
@@ -701,26 +701,26 @@  discard block
 block discarded – undo
701 701
 	public function payments_data() {
702 702
 
703 703
 		$per_page   = $this->per_page;
704
-		$orderby    = isset( $_GET['orderby'] ) ? urldecode( $_GET['orderby'] ) : 'ID';
705
-		$order      = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC';
706
-		$user       = isset( $_GET['user'] ) ? $_GET['user'] : null;
707
-		$status     = isset( $_GET['status'] ) ? $_GET['status'] : give_get_payment_status_keys();
708
-		$meta_key   = isset( $_GET['meta_key'] ) ? $_GET['meta_key'] : null;
709
-		$year       = isset( $_GET['year'] ) ? $_GET['year'] : null;
710
-		$month      = isset( $_GET['m'] ) ? $_GET['m'] : null;
711
-		$day        = isset( $_GET['day'] ) ? $_GET['day'] : null;
712
-		$search     = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null;
713
-		$start_date = isset( $_GET['start-date'] ) ? sanitize_text_field( $_GET['start-date'] ) : null;
714
-		$end_date   = isset( $_GET['end-date'] ) ? sanitize_text_field( $_GET['end-date'] ) : $start_date;
715
-
716
-		if ( ! empty( $search ) ) {
704
+		$orderby    = isset($_GET['orderby']) ? urldecode($_GET['orderby']) : 'ID';
705
+		$order      = isset($_GET['order']) ? $_GET['order'] : 'DESC';
706
+		$user       = isset($_GET['user']) ? $_GET['user'] : null;
707
+		$status     = isset($_GET['status']) ? $_GET['status'] : give_get_payment_status_keys();
708
+		$meta_key   = isset($_GET['meta_key']) ? $_GET['meta_key'] : null;
709
+		$year       = isset($_GET['year']) ? $_GET['year'] : null;
710
+		$month      = isset($_GET['m']) ? $_GET['m'] : null;
711
+		$day        = isset($_GET['day']) ? $_GET['day'] : null;
712
+		$search     = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : null;
713
+		$start_date = isset($_GET['start-date']) ? sanitize_text_field($_GET['start-date']) : null;
714
+		$end_date   = isset($_GET['end-date']) ? sanitize_text_field($_GET['end-date']) : $start_date;
715
+
716
+		if ( ! empty($search)) {
717 717
 			$status = 'any'; // Force all payment statuses when searching.
718 718
 		}
719 719
 
720 720
 		$args = array(
721 721
 			'output'     => 'payments',
722 722
 			'number'     => $per_page,
723
-			'page'       => isset( $_GET['paged'] ) ? $_GET['paged'] : null,
723
+			'page'       => isset($_GET['paged']) ? $_GET['paged'] : null,
724 724
 			'orderby'    => $orderby,
725 725
 			'order'      => $order,
726 726
 			'user'       => $user,
@@ -734,12 +734,12 @@  discard block
 block discarded – undo
734 734
 			'end_date'   => $end_date,
735 735
 		);
736 736
 
737
-		if ( is_string( $search ) && false !== strpos( $search, 'txn:' ) ) {
737
+		if (is_string($search) && false !== strpos($search, 'txn:')) {
738 738
 			$args['search_in_notes'] = true;
739
-			$args['s']               = trim( str_replace( 'txn:', '', $args['s'] ) );
739
+			$args['s']               = trim(str_replace('txn:', '', $args['s']));
740 740
 		}
741 741
 
742
-		$p_query = new Give_Payments_Query( $args );
742
+		$p_query = new Give_Payments_Query($args);
743 743
 
744 744
 		return $p_query->get_payments();
745 745
 
@@ -759,17 +759,17 @@  discard block
 block discarded – undo
759 759
 	 */
760 760
 	public function prepare_items() {
761 761
 
762
-		wp_reset_vars( array( 'action', 'payment', 'orderby', 'order', 's' ) );
762
+		wp_reset_vars(array('action', 'payment', 'orderby', 'order', 's'));
763 763
 
764 764
 		$columns  = $this->get_columns();
765 765
 		$hidden   = array(); // No hidden columns.
766 766
 		$sortable = $this->get_sortable_columns();
767 767
 		$data     = $this->payments_data();
768
-		$status   = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
768
+		$status   = isset($_GET['status']) ? $_GET['status'] : 'any';
769 769
 
770
-		$this->_column_headers = array( $columns, $hidden, $sortable );
770
+		$this->_column_headers = array($columns, $hidden, $sortable);
771 771
 
772
-		switch ( $status ) {
772
+		switch ($status) {
773 773
 			case 'publish':
774 774
 				$total_items = $this->complete_count;
775 775
 				break;
@@ -796,19 +796,19 @@  discard block
 block discarded – undo
796 796
 				break;
797 797
 			default:
798 798
 				// Retrieve the count of the non-default-Give status.
799
-				$count       = wp_count_posts( 'give_payment' );
800
-				$total_items = isset( $count->{$status} ) ? $count->{$status} : 0;
799
+				$count       = wp_count_posts('give_payment');
800
+				$total_items = isset($count->{$status} ) ? $count->{$status} : 0;
801 801
 				break;
802 802
 		}
803 803
 
804 804
 		$this->items = $data;
805 805
 
806
-		$this->set_pagination_args( array(
806
+		$this->set_pagination_args(array(
807 807
 				'total_items' => $total_items,
808 808
 				// We have to calculate the total number of items.
809 809
 				'per_page'    => $this->per_page,
810 810
 				// We have to determine how many items to show on a page.
811
-				'total_pages' => ceil( $total_items / $this->per_page ),
811
+				'total_pages' => ceil($total_items / $this->per_page),
812 812
 				// We have to calculate the total number of pages.
813 813
 			)
814 814
 		);
Please login to merge, or discard this patch.
includes/payments/functions.php 1 patch
Spacing   +408 added lines, -408 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
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @return object $payments Payments retrieved from the database
45 45
  */
46
-function give_get_payments( $args = array() ) {
46
+function give_get_payments($args = array()) {
47 47
 
48 48
 	// Fallback to post objects to ensure backwards compatibility.
49
-	if ( ! isset( $args['output'] ) ) {
49
+	if ( ! isset($args['output'])) {
50 50
 		$args['output'] = 'posts';
51 51
 	}
52 52
 
53
-	$args     = apply_filters( 'give_get_payments_args', $args );
54
-	$payments = new Give_Payments_Query( $args );
53
+	$args     = apply_filters('give_get_payments_args', $args);
54
+	$payments = new Give_Payments_Query($args);
55 55
 
56 56
 	return $payments->get_payments();
57 57
 }
@@ -66,48 +66,48 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return mixed
68 68
  */
69
-function give_get_payment_by( $field = '', $value = '' ) {
69
+function give_get_payment_by($field = '', $value = '') {
70 70
 
71
-	if ( empty( $field ) || empty( $value ) ) {
71
+	if (empty($field) || empty($value)) {
72 72
 		return false;
73 73
 	}
74 74
 
75
-	switch ( strtolower( $field ) ) {
75
+	switch (strtolower($field)) {
76 76
 
77 77
 		case 'id':
78
-			$payment = new Give_Payment( $value );
78
+			$payment = new Give_Payment($value);
79 79
 			$id      = $payment->ID;
80 80
 
81
-			if ( empty( $id ) ) {
81
+			if (empty($id)) {
82 82
 				return false;
83 83
 			}
84 84
 
85 85
 			break;
86 86
 
87 87
 		case 'key':
88
-			$payment = give_get_payments( array(
88
+			$payment = give_get_payments(array(
89 89
 				'meta_key'       => '_give_payment_purchase_key',
90 90
 				'meta_value'     => $value,
91 91
 				'posts_per_page' => 1,
92 92
 				'fields'         => 'ids',
93
-			) );
93
+			));
94 94
 
95
-			if ( $payment ) {
96
-				$payment = new Give_Payment( $payment[0] );
95
+			if ($payment) {
96
+				$payment = new Give_Payment($payment[0]);
97 97
 			}
98 98
 
99 99
 			break;
100 100
 
101 101
 		case 'payment_number':
102
-			$payment = give_get_payments( array(
102
+			$payment = give_get_payments(array(
103 103
 				'meta_key'       => '_give_payment_number',
104 104
 				'meta_value'     => $value,
105 105
 				'posts_per_page' => 1,
106 106
 				'fields'         => 'ids',
107
-			) );
107
+			));
108 108
 
109
-			if ( $payment ) {
110
-				$payment = new Give_Payment( $payment[0] );
109
+			if ($payment) {
110
+				$payment = new Give_Payment($payment[0]);
111 111
 			}
112 112
 
113 113
 			break;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			return false;
117 117
 	}
118 118
 
119
-	if ( $payment ) {
119
+	if ($payment) {
120 120
 		return $payment;
121 121
 	}
122 122
 
@@ -132,23 +132,23 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return int|bool Payment ID if payment is inserted, false otherwise.
134 134
  */
135
-function give_insert_payment( $payment_data = array() ) {
135
+function give_insert_payment($payment_data = array()) {
136 136
 
137
-	if ( empty( $payment_data ) ) {
137
+	if (empty($payment_data)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	$payment    = new Give_Payment();
142
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
143
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
144
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
145
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
146
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
142
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
143
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
144
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
145
+	$price_id   = give_get_payment_meta_price_id($payment_data);
146
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
147 147
 
148 148
 	// Set properties.
149 149
 	$payment->total          = $payment_data['price'];
150
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
151
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency();
150
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
151
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency();
152 152
 	$payment->user_info      = $payment_data['user_info'];
153 153
 	$payment->gateway        = $gateway;
154 154
 	$payment->form_title     = $form_title;
@@ -162,31 +162,31 @@  discard block
 block discarded – undo
162 162
 	$payment->ip             = give_get_ip();
163 163
 	$payment->key            = $payment_data['purchase_key'];
164 164
 	$payment->mode           = give_is_test_mode() ? 'test' : 'live';
165
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
165
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
166 166
 
167 167
 	// Add the donation.
168 168
 	$args = array(
169 169
 		'price'    => $payment->total,
170 170
 		'price_id' => $payment->price_id,
171
-		'fees'     => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array(),
171
+		'fees'     => isset($payment_data['fees']) ? $payment_data['fees'] : array(),
172 172
 	);
173 173
 
174
-	$payment->add_donation( $payment->form_id, $args );
174
+	$payment->add_donation($payment->form_id, $args);
175 175
 
176 176
 	// Set date if present.
177
-	if ( isset( $payment_data['post_date'] ) ) {
177
+	if (isset($payment_data['post_date'])) {
178 178
 		$payment->date = $payment_data['post_date'];
179 179
 	}
180 180
 
181 181
 	// Handle sequential payments.
182
-	if ( give_get_option( 'enable_sequential' ) ) {
182
+	if (give_get_option('enable_sequential')) {
183 183
 		$number          = give_get_next_payment_number();
184
-		$payment->number = give_format_payment_number( $number );
185
-		update_option( 'give_last_payment_number', $number );
184
+		$payment->number = give_format_payment_number($number);
185
+		update_option('give_last_payment_number', $number);
186 186
 	}
187 187
 
188 188
 	// Clear the user's donation cache.
189
-	delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' );
189
+	delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases');
190 190
 
191 191
 	// Save payment.
192 192
 	$payment->save();
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 	 * @param int   $payment_id   The payment ID.
200 200
 	 * @param array $payment_data Arguments passed.
201 201
 	 */
202
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
202
+	do_action('give_insert_payment', $payment->ID, $payment_data);
203 203
 
204 204
 	// Return payment ID upon success.
205
-	if ( ! empty( $payment->ID ) ) {
205
+	if ( ! empty($payment->ID)) {
206 206
 		return $payment->ID;
207 207
 	}
208 208
 
@@ -218,10 +218,10 @@  discard block
 block discarded – undo
218 218
  *
219 219
  * @return bool|int
220 220
  */
221
-function give_create_payment( $payment_data ) {
221
+function give_create_payment($payment_data) {
222 222
 
223
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
224
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
223
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
224
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
225 225
 
226 226
 	// Collect payment data.
227 227
 	$insert_payment_data = array(
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @param array $insert_payment_data
247 247
 	 */
248
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
248
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
249 249
 
250 250
 	// Record the pending payment.
251
-	return give_insert_payment( $insert_payment_data );
251
+	return give_insert_payment($insert_payment_data);
252 252
 }
253 253
 
254 254
 /**
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
  *
262 262
  * @return bool
263 263
  */
264
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
264
+function give_update_payment_status($payment_id, $new_status = 'publish') {
265 265
 
266
-	$payment         = new Give_Payment( $payment_id );
266
+	$payment         = new Give_Payment($payment_id);
267 267
 	$payment->status = $new_status;
268 268
 	$updated         = $payment->save();
269 269
 
@@ -282,37 +282,37 @@  discard block
 block discarded – undo
282 282
  *
283 283
  * @return void
284 284
  */
285
-function give_delete_purchase( $payment_id = 0, $update_customer = true ) {
285
+function give_delete_purchase($payment_id = 0, $update_customer = true) {
286 286
 	global $give_logs;
287 287
 
288
-	$payment     = new Give_Payment( $payment_id );
289
-	$amount      = give_get_payment_amount( $payment_id );
288
+	$payment     = new Give_Payment($payment_id);
289
+	$amount      = give_get_payment_amount($payment_id);
290 290
 	$status      = $payment->post_status;
291
-	$customer_id = give_get_payment_customer_id( $payment_id );
292
-	$customer    = new Give_Customer( $customer_id );
291
+	$customer_id = give_get_payment_customer_id($payment_id);
292
+	$customer    = new Give_Customer($customer_id);
293 293
 
294 294
 	// Only undo donations that aren't these statuses.
295
-	$dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array(
295
+	$dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array(
296 296
 		'pending',
297 297
 		'cancelled',
298
-	) );
298
+	));
299 299
 
300
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
301
-		give_undo_purchase( false, $payment_id );
300
+	if ( ! in_array($status, $dont_undo_statuses)) {
301
+		give_undo_purchase(false, $payment_id);
302 302
 	}
303 303
 
304
-	if ( $status == 'publish' ) {
304
+	if ($status == 'publish') {
305 305
 
306 306
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
307
-		give_decrease_total_earnings( $amount );
307
+		give_decrease_total_earnings($amount);
308 308
 		// Clear the This Month earnings (this_monththis_month is NOT a typo).
309
-		delete_transient( md5( 'give_earnings_this_monththis_month' ) );
309
+		delete_transient(md5('give_earnings_this_monththis_month'));
310 310
 
311
-		if ( $customer->id && $update_customer ) {
311
+		if ($customer->id && $update_customer) {
312 312
 
313 313
 			// Decrement the stats for the donor.
314 314
 			$customer->decrease_purchase_count();
315
-			$customer->decrease_value( $amount );
315
+			$customer->decrease_value($amount);
316 316
 
317 317
 		}
318 318
 	}
@@ -324,17 +324,17 @@  discard block
 block discarded – undo
324 324
 	 *
325 325
 	 * @param int $payment_id Payment ID.
326 326
 	 */
327
-	do_action( 'give_payment_delete', $payment_id );
327
+	do_action('give_payment_delete', $payment_id);
328 328
 
329
-	if ( $customer->id && $update_customer ) {
329
+	if ($customer->id && $update_customer) {
330 330
 
331 331
 		// Remove the payment ID from the donor.
332
-		$customer->remove_payment( $payment_id );
332
+		$customer->remove_payment($payment_id);
333 333
 
334 334
 	}
335 335
 
336 336
 	// Remove the payment.
337
-	wp_delete_post( $payment_id, true );
337
+	wp_delete_post($payment_id, true);
338 338
 
339 339
 	// Remove related sale log entries.
340 340
 	$give_logs->delete_logs(
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
 	 * @param int $payment_id Payment ID.
357 357
 	 */
358
-	do_action( 'give_payment_deleted', $payment_id );
358
+	do_action('give_payment_deleted', $payment_id);
359 359
 }
360 360
 
361 361
 /**
@@ -371,25 +371,25 @@  discard block
 block discarded – undo
371 371
  *
372 372
  * @return void
373 373
  */
374
-function give_undo_purchase( $form_id = false, $payment_id ) {
374
+function give_undo_purchase($form_id = false, $payment_id) {
375 375
 
376
-	if ( ! empty( $form_id ) ) {
376
+	if ( ! empty($form_id)) {
377 377
 		$form_id = false;
378
-		_give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' );
378
+		_give_deprected_argument('form_id', 'give_undo_purchase', '1.5');
379 379
 	}
380 380
 
381
-	$payment = new Give_Payment( $payment_id );
381
+	$payment = new Give_Payment($payment_id);
382 382
 
383
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
384
-	if ( true === $maybe_decrease_earnings ) {
383
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
384
+	if (true === $maybe_decrease_earnings) {
385 385
 		// Decrease earnings.
386
-		give_decrease_earnings( $payment->form_id, $payment->total );
386
+		give_decrease_earnings($payment->form_id, $payment->total);
387 387
 	}
388 388
 
389
-	$maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id );
390
-	if ( true === $maybe_decrease_sales ) {
389
+	$maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id);
390
+	if (true === $maybe_decrease_sales) {
391 391
 		// Decrease donation count.
392
-		give_decrease_purchase_count( $payment->form_id );
392
+		give_decrease_purchase_count($payment->form_id);
393 393
 	}
394 394
 
395 395
 }
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
  *
407 407
  * @return object $stats Contains the number of payments per payment status.
408 408
  */
409
-function give_count_payments( $args = array() ) {
409
+function give_count_payments($args = array()) {
410 410
 
411 411
 	global $wpdb;
412 412
 
@@ -418,18 +418,18 @@  discard block
 block discarded – undo
418 418
 		'form_id'    => null,
419 419
 	);
420 420
 
421
-	$args = wp_parse_args( $args, $defaults );
421
+	$args = wp_parse_args($args, $defaults);
422 422
 
423 423
 	$select = 'SELECT p.post_status,count( * ) AS num_posts';
424 424
 	$join   = '';
425 425
 	$where  = "WHERE p.post_type = 'give_payment'";
426 426
 
427 427
 	// Count payments for a specific user.
428
-	if ( ! empty( $args['user'] ) ) {
428
+	if ( ! empty($args['user'])) {
429 429
 
430
-		if ( is_email( $args['user'] ) ) {
430
+		if (is_email($args['user'])) {
431 431
 			$field = 'email';
432
-		} elseif ( is_numeric( $args['user'] ) ) {
432
+		} elseif (is_numeric($args['user'])) {
433 433
 			$field = 'id';
434 434
 		} else {
435 435
 			$field = '';
@@ -437,105 +437,105 @@  discard block
 block discarded – undo
437 437
 
438 438
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
439 439
 
440
-		if ( ! empty( $field ) ) {
440
+		if ( ! empty($field)) {
441 441
 			$where .= "
442 442
 				AND m.meta_key = '_give_payment_user_{$field}'
443 443
 				AND m.meta_value = '{$args['user']}'";
444 444
 		}
445 445
 
446 446
 		// Count payments for a search.
447
-	} elseif ( ! empty( $args['s'] ) ) {
447
+	} elseif ( ! empty($args['s'])) {
448 448
 
449
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
449
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
450 450
 
451
-			if ( is_email( $args['s'] ) ) {
451
+			if (is_email($args['s'])) {
452 452
 				$field = '_give_payment_user_email';
453 453
 			} else {
454 454
 				$field = '_give_payment_purchase_key';
455 455
 			}
456 456
 
457
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
458
-			$where .= $wpdb->prepare( '
457
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
458
+			$where .= $wpdb->prepare('
459 459
                 AND m.meta_key = %s
460 460
                 AND m.meta_value = %s',
461 461
 				$field,
462 462
 				$args['s']
463 463
 			);
464 464
 
465
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
465
+		} elseif ('#' == substr($args['s'], 0, 1)) {
466 466
 
467
-			$search = str_replace( '#:', '', $args['s'] );
468
-			$search = str_replace( '#', '', $search );
467
+			$search = str_replace('#:', '', $args['s']);
468
+			$search = str_replace('#', '', $search);
469 469
 
470 470
 			$select = 'SELECT p2.post_status,count( * ) AS num_posts ';
471 471
 			$join   = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID ";
472 472
 			$join   .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID ";
473 473
 			$where  = "WHERE p.post_type = 'give_log' ";
474
-			$where  .= $wpdb->prepare( 'AND p.post_parent = %d} ', $search );
474
+			$where  .= $wpdb->prepare('AND p.post_parent = %d} ', $search);
475 475
 
476
-		} elseif ( is_numeric( $args['s'] ) ) {
476
+		} elseif (is_numeric($args['s'])) {
477 477
 
478
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
479
-			$where .= $wpdb->prepare( "
478
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
479
+			$where .= $wpdb->prepare("
480 480
 				AND m.meta_key = '_give_payment_user_id'
481 481
 				AND m.meta_value = %d",
482 482
 				$args['s']
483 483
 			);
484 484
 
485 485
 		} else {
486
-			$search = $wpdb->esc_like( $args['s'] );
487
-			$search = '%' . $search . '%';
486
+			$search = $wpdb->esc_like($args['s']);
487
+			$search = '%'.$search.'%';
488 488
 
489
-			$where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search );
489
+			$where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search);
490 490
 		}
491 491
 	}
492 492
 
493
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
493
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
494 494
 
495
-		$where .= $wpdb->prepare( ' AND p.post_parent = %d', $args['form_id'] );
495
+		$where .= $wpdb->prepare(' AND p.post_parent = %d', $args['form_id']);
496 496
 
497 497
 	}
498 498
 	// Limit payments count by date.
499
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
499
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
500 500
 
501
-		$date_parts = explode( '/', $args['start-date'] );
502
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
503
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
504
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
501
+		$date_parts = explode('/', $args['start-date']);
502
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
503
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
504
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
505 505
 
506
-		$is_date = checkdate( $month, $day, $year );
507
-		if ( false !== $is_date ) {
506
+		$is_date = checkdate($month, $day, $year);
507
+		if (false !== $is_date) {
508 508
 
509
-			$date  = new DateTime( $args['start-date'] );
510
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
509
+			$date = new DateTime($args['start-date']);
510
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
511 511
 
512 512
 		}
513 513
 
514 514
 		// Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class).
515
-		if ( empty( $args['end-date'] ) ) {
515
+		if (empty($args['end-date'])) {
516 516
 			$args['end-date'] = $args['start-date'];
517 517
 		}
518 518
 	}
519 519
 
520
-	if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
520
+	if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) {
521 521
 
522
-		$date_parts = explode( '/', $args['end-date'] );
522
+		$date_parts = explode('/', $args['end-date']);
523 523
 
524
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
525
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
526
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
524
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
525
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
526
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
527 527
 
528
-		$is_date = checkdate( $month, $day, $year );
529
-		if ( false !== $is_date ) {
528
+		$is_date = checkdate($month, $day, $year);
529
+		if (false !== $is_date) {
530 530
 
531
-			$date  = new DateTime( $args['end-date'] );
532
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
531
+			$date = new DateTime($args['end-date']);
532
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
533 533
 
534 534
 		}
535 535
 	}
536 536
 
537
-	$where = apply_filters( 'give_count_payments_where', $where );
538
-	$join  = apply_filters( 'give_count_payments_join', $join );
537
+	$where = apply_filters('give_count_payments_where', $where);
538
+	$join  = apply_filters('give_count_payments_join', $join);
539 539
 
540 540
 	$query = "$select
541 541
 		FROM $wpdb->posts p
@@ -544,36 +544,36 @@  discard block
 block discarded – undo
544 544
 		GROUP BY p.post_status
545 545
 	";
546 546
 
547
-	$cache_key = md5( $query );
547
+	$cache_key = md5($query);
548 548
 
549
-	$count = wp_cache_get( $cache_key, 'counts' );
550
-	if ( false !== $count ) {
549
+	$count = wp_cache_get($cache_key, 'counts');
550
+	if (false !== $count) {
551 551
 		return $count;
552 552
 	}
553 553
 
554
-	$count = $wpdb->get_results( $query, ARRAY_A );
554
+	$count = $wpdb->get_results($query, ARRAY_A);
555 555
 
556 556
 	$stats    = array();
557 557
 	$statuses = get_post_stati();
558
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
559
-		unset( $statuses['private'] );
558
+	if (isset($statuses['private']) && empty($args['s'])) {
559
+		unset($statuses['private']);
560 560
 	}
561 561
 
562
-	foreach ( $statuses as $state ) {
563
-		$stats[ $state ] = 0;
562
+	foreach ($statuses as $state) {
563
+		$stats[$state] = 0;
564 564
 	}
565 565
 
566
-	foreach ( (array) $count as $row ) {
566
+	foreach ((array) $count as $row) {
567 567
 
568
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
568
+		if ('private' == $row['post_status'] && empty($args['s'])) {
569 569
 			continue;
570 570
 		}
571 571
 
572
-		$stats[ $row['post_status'] ] = $row['num_posts'];
572
+		$stats[$row['post_status']] = $row['num_posts'];
573 573
 	}
574 574
 
575 575
 	$stats = (object) $stats;
576
-	wp_cache_set( $cache_key, $stats, 'counts' );
576
+	wp_cache_set($cache_key, $stats, 'counts');
577 577
 
578 578
 	return $stats;
579 579
 }
@@ -588,11 +588,11 @@  discard block
 block discarded – undo
588 588
  *
589 589
  * @return bool $exists True if payment exists, false otherwise.
590 590
  */
591
-function give_check_for_existing_payment( $payment_id ) {
591
+function give_check_for_existing_payment($payment_id) {
592 592
 	$exists  = false;
593
-	$payment = new Give_Payment( $payment_id );
593
+	$payment = new Give_Payment($payment_id);
594 594
 
595
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
595
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
596 596
 		$exists = true;
597 597
 	}
598 598
 
@@ -610,31 +610,31 @@  discard block
 block discarded – undo
610 610
  *
611 611
  * @return bool|mixed True if payment status exists, false otherwise.
612 612
  */
613
-function give_get_payment_status( $payment, $return_label = false ) {
613
+function give_get_payment_status($payment, $return_label = false) {
614 614
 
615
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
615
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
616 616
 		return false;
617 617
 	}
618 618
 
619 619
 	$statuses = give_get_payment_statuses();
620 620
 
621
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
621
+	if ( ! is_array($statuses) || empty($statuses)) {
622 622
 		return false;
623 623
 	}
624 624
 
625 625
 	// Get payment object if no already given.
626
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
626
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
627 627
 
628
-	if ( array_key_exists( $payment->status, $statuses ) ) {
629
-		if ( true === $return_label ) {
628
+	if (array_key_exists($payment->status, $statuses)) {
629
+		if (true === $return_label) {
630 630
 			// Return translated status label.
631
-			return $statuses[ $payment->status ];
631
+			return $statuses[$payment->status];
632 632
 		} else {
633 633
 			// Account that our 'publish' status is labeled 'Complete'
634 634
 			$post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status;
635 635
 
636 636
 			// Make sure we're matching cases, since they matter
637
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
637
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
638 638
 		}
639 639
 	}
640 640
 
@@ -650,17 +650,17 @@  discard block
 block discarded – undo
650 650
  */
651 651
 function give_get_payment_statuses() {
652 652
 	$payment_statuses = array(
653
-		'pending'     => __( 'Pending', 'give' ),
654
-		'publish'     => __( 'Complete', 'give' ),
655
-		'refunded'    => __( 'Refunded', 'give' ),
656
-		'failed'      => __( 'Failed', 'give' ),
657
-		'cancelled'   => __( 'Cancelled', 'give' ),
658
-		'abandoned'   => __( 'Abandoned', 'give' ),
659
-		'preapproval' => __( 'Pre-Approved', 'give' ),
660
-		'revoked'     => __( 'Revoked', 'give' ),
653
+		'pending'     => __('Pending', 'give'),
654
+		'publish'     => __('Complete', 'give'),
655
+		'refunded'    => __('Refunded', 'give'),
656
+		'failed'      => __('Failed', 'give'),
657
+		'cancelled'   => __('Cancelled', 'give'),
658
+		'abandoned'   => __('Abandoned', 'give'),
659
+		'preapproval' => __('Pre-Approved', 'give'),
660
+		'revoked'     => __('Revoked', 'give'),
661 661
 	);
662 662
 
663
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
663
+	return apply_filters('give_payment_statuses', $payment_statuses);
664 664
 }
665 665
 
666 666
 /**
@@ -673,10 +673,10 @@  discard block
 block discarded – undo
673 673
  * @return array $payment_status All the available payment statuses.
674 674
  */
675 675
 function give_get_payment_status_keys() {
676
-	$statuses = array_keys( give_get_payment_statuses() );
677
-	asort( $statuses );
676
+	$statuses = array_keys(give_get_payment_statuses());
677
+	asort($statuses);
678 678
 
679
-	return array_values( $statuses );
679
+	return array_values($statuses);
680 680
 }
681 681
 
682 682
 /**
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
  *
692 692
  * @return int $earnings  Earnings
693 693
  */
694
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
694
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
695 695
 
696 696
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
697 697
 	global $wpdb;
@@ -701,41 +701,41 @@  discard block
 block discarded – undo
701 701
 		'nopaging'               => true,
702 702
 		'year'                   => $year,
703 703
 		'monthnum'               => $month_num,
704
-		'post_status'            => array( 'publish' ),
704
+		'post_status'            => array('publish'),
705 705
 		'fields'                 => 'ids',
706 706
 		'update_post_term_cache' => false,
707 707
 	);
708
-	if ( ! empty( $day ) ) {
708
+	if ( ! empty($day)) {
709 709
 		$args['day'] = $day;
710 710
 	}
711 711
 
712
-	if ( ! empty( $hour ) ) {
712
+	if ( ! empty($hour)) {
713 713
 		$args['hour'] = $hour;
714 714
 	}
715 715
 
716
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
717
-	$key  = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
716
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
717
+	$key  = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
718 718
 
719
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
719
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
720 720
 		$earnings = false;
721 721
 	} else {
722
-		$earnings = get_transient( $key );
722
+		$earnings = get_transient($key);
723 723
 	}
724 724
 
725
-	if ( false === $earnings ) {
726
-		$sales    = get_posts( $args );
725
+	if (false === $earnings) {
726
+		$sales    = get_posts($args);
727 727
 		$earnings = 0;
728
-		if ( $sales ) {
729
-			$sales = implode( ',', $sales );
728
+		if ($sales) {
729
+			$sales = implode(',', $sales);
730 730
 
731
-			$earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" );
731
+			$earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})");
732 732
 
733 733
 		}
734 734
 		// Cache the results for one hour.
735
-		set_transient( $key, $earnings, HOUR_IN_SECONDS );
735
+		set_transient($key, $earnings, HOUR_IN_SECONDS);
736 736
 	}
737 737
 
738
-	return round( $earnings, 2 );
738
+	return round($earnings, 2);
739 739
 }
740 740
 
741 741
 /**
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
  *
751 751
  * @return int $count     Sales
752 752
  */
753
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
753
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
754 754
 
755 755
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
756 756
 	$args = array(
@@ -758,14 +758,14 @@  discard block
 block discarded – undo
758 758
 		'nopaging'               => true,
759 759
 		'year'                   => $year,
760 760
 		'fields'                 => 'ids',
761
-		'post_status'            => array( 'publish' ),
761
+		'post_status'            => array('publish'),
762 762
 		'update_post_meta_cache' => false,
763 763
 		'update_post_term_cache' => false,
764 764
 	);
765 765
 
766
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
766
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
767 767
 
768
-	if ( false === $show_free ) {
768
+	if (false === $show_free) {
769 769
 		$args['meta_query'] = array(
770 770
 			array(
771 771
 				'key'     => '_give_payment_total',
@@ -776,33 +776,33 @@  discard block
 block discarded – undo
776 776
 		);
777 777
 	}
778 778
 
779
-	if ( ! empty( $month_num ) ) {
779
+	if ( ! empty($month_num)) {
780 780
 		$args['monthnum'] = $month_num;
781 781
 	}
782 782
 
783
-	if ( ! empty( $day ) ) {
783
+	if ( ! empty($day)) {
784 784
 		$args['day'] = $day;
785 785
 	}
786 786
 
787
-	if ( ! empty( $hour ) ) {
787
+	if ( ! empty($hour)) {
788 788
 		$args['hour'] = $hour;
789 789
 	}
790 790
 
791
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
791
+	$args = apply_filters('give_get_sales_by_date_args', $args);
792 792
 
793
-	$key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 );
793
+	$key = 'give_stats_'.substr(md5(serialize($args)), 0, 15);
794 794
 
795
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
795
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
796 796
 		$count = false;
797 797
 	} else {
798
-		$count = get_transient( $key );
798
+		$count = get_transient($key);
799 799
 	}
800 800
 
801
-	if ( false === $count ) {
802
-		$sales = new WP_Query( $args );
801
+	if (false === $count) {
802
+		$sales = new WP_Query($args);
803 803
 		$count = (int) $sales->post_count;
804 804
 		// Cache the results for one hour.
805
-		set_transient( $key, $count, HOUR_IN_SECONDS );
805
+		set_transient($key, $count, HOUR_IN_SECONDS);
806 806
 	}
807 807
 
808 808
 	return $count;
@@ -817,19 +817,19 @@  discard block
 block discarded – undo
817 817
  *
818 818
  * @return bool $ret True if complete, false otherwise.
819 819
  */
820
-function give_is_payment_complete( $payment_id ) {
821
-	$payment = new Give_Payment( $payment_id );
820
+function give_is_payment_complete($payment_id) {
821
+	$payment = new Give_Payment($payment_id);
822 822
 
823 823
 	$ret = false;
824 824
 
825
-	if ( $payment->ID > 0 ) {
825
+	if ($payment->ID > 0) {
826 826
 
827
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
827
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
828 828
 			$ret = true;
829 829
 		}
830 830
 	}
831 831
 
832
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
832
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
833 833
 }
834 834
 
835 835
 /**
@@ -855,57 +855,57 @@  discard block
 block discarded – undo
855 855
  */
856 856
 function give_get_total_earnings() {
857 857
 
858
-	$total = get_option( 'give_earnings_total', false );
858
+	$total = get_option('give_earnings_total', false);
859 859
 
860 860
 	// If no total stored in DB, use old method of calculating total earnings.
861
-	if ( false === $total ) {
861
+	if (false === $total) {
862 862
 
863 863
 		global $wpdb;
864 864
 
865
-		$total = get_transient( 'give_earnings_total' );
865
+		$total = get_transient('give_earnings_total');
866 866
 
867
-		if ( false === $total ) {
867
+		if (false === $total) {
868 868
 
869 869
 			$total = (float) 0;
870 870
 
871
-			$args = apply_filters( 'give_get_total_earnings_args', array(
871
+			$args = apply_filters('give_get_total_earnings_args', array(
872 872
 				'offset' => 0,
873
-				'number' => - 1,
874
-				'status' => array( 'publish' ),
873
+				'number' => -1,
874
+				'status' => array('publish'),
875 875
 				'fields' => 'ids',
876
-			) );
876
+			));
877 877
 
878
-			$payments = give_get_payments( $args );
879
-			if ( $payments ) {
878
+			$payments = give_get_payments($args);
879
+			if ($payments) {
880 880
 
881 881
 				/**
882 882
 				 * If performing a donation, we need to skip the very last payment in the database,
883 883
 				 * since it calls give_increase_total_earnings() on completion,
884 884
 				 * which results in duplicated earnings for the very first donation.
885 885
 				 */
886
-				if ( did_action( 'give_update_payment_status' ) ) {
887
-					array_pop( $payments );
886
+				if (did_action('give_update_payment_status')) {
887
+					array_pop($payments);
888 888
 				}
889 889
 
890
-				if ( ! empty( $payments ) ) {
891
-					$payments = implode( ',', $payments );
892
-					$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
890
+				if ( ! empty($payments)) {
891
+					$payments = implode(',', $payments);
892
+					$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
893 893
 				}
894 894
 			}
895 895
 
896 896
 			// Cache results for 1 day. This cache is cleared automatically when a payment is made.
897
-			set_transient( 'give_earnings_total', $total, 86400 );
897
+			set_transient('give_earnings_total', $total, 86400);
898 898
 
899 899
 			// Store the total for the first time.
900
-			update_option( 'give_earnings_total', $total );
900
+			update_option('give_earnings_total', $total);
901 901
 		}
902 902
 	}
903 903
 
904
-	if ( $total < 0 ) {
904
+	if ($total < 0) {
905 905
 		$total = 0; // Don't ever show negative earnings.
906 906
 	}
907 907
 
908
-	return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) );
908
+	return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter()));
909 909
 }
910 910
 
911 911
 /**
@@ -918,10 +918,10 @@  discard block
 block discarded – undo
918 918
  *
919 919
  * @return float $total  Total earnings.
920 920
  */
921
-function give_increase_total_earnings( $amount = 0 ) {
921
+function give_increase_total_earnings($amount = 0) {
922 922
 	$total = give_get_total_earnings();
923 923
 	$total += $amount;
924
-	update_option( 'give_earnings_total', $total );
924
+	update_option('give_earnings_total', $total);
925 925
 
926 926
 	return $total;
927 927
 }
@@ -935,13 +935,13 @@  discard block
 block discarded – undo
935 935
  *
936 936
  * @return float $total Total earnings.
937 937
  */
938
-function give_decrease_total_earnings( $amount = 0 ) {
938
+function give_decrease_total_earnings($amount = 0) {
939 939
 	$total = give_get_total_earnings();
940 940
 	$total -= $amount;
941
-	if ( $total < 0 ) {
941
+	if ($total < 0) {
942 942
 		$total = 0;
943 943
 	}
944
-	update_option( 'give_earnings_total', $total );
944
+	update_option('give_earnings_total', $total);
945 945
 
946 946
 	return $total;
947 947
 }
@@ -957,10 +957,10 @@  discard block
 block discarded – undo
957 957
  *
958 958
  * @return mixed $meta Payment Meta.
959 959
  */
960
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
961
-	$payment = new Give_Payment( $payment_id );
960
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
961
+	$payment = new Give_Payment($payment_id);
962 962
 
963
-	return $payment->get_meta( $meta_key, $single );
963
+	return $payment->get_meta($meta_key, $single);
964 964
 }
965 965
 
966 966
 /**
@@ -973,10 +973,10 @@  discard block
 block discarded – undo
973 973
  *
974 974
  * @return mixed Meta ID if successful, false if unsuccessful.
975 975
  */
976
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
977
-	$payment = new Give_Payment( $payment_id );
976
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
977
+	$payment = new Give_Payment($payment_id);
978 978
 
979
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
979
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
980 980
 }
981 981
 
982 982
 /**
@@ -988,8 +988,8 @@  discard block
 block discarded – undo
988 988
  *
989 989
  * @return string $user_info User Info Meta Values.
990 990
  */
991
-function give_get_payment_meta_user_info( $payment_id ) {
992
-	$payment = new Give_Payment( $payment_id );
991
+function give_get_payment_meta_user_info($payment_id) {
992
+	$payment = new Give_Payment($payment_id);
993 993
 
994 994
 	return $payment->user_info;
995 995
 }
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
  *
1006 1006
  * @return int $form_id Form ID.
1007 1007
  */
1008
-function give_get_payment_form_id( $payment_id ) {
1009
-	$payment = new Give_Payment( $payment_id );
1008
+function give_get_payment_form_id($payment_id) {
1009
+	$payment = new Give_Payment($payment_id);
1010 1010
 
1011 1011
 	return $payment->form_id;
1012 1012
 }
@@ -1020,8 +1020,8 @@  discard block
 block discarded – undo
1020 1020
  *
1021 1021
  * @return string $email User email.
1022 1022
  */
1023
-function give_get_payment_user_email( $payment_id ) {
1024
-	$payment = new Give_Payment( $payment_id );
1023
+function give_get_payment_user_email($payment_id) {
1024
+	$payment = new Give_Payment($payment_id);
1025 1025
 
1026 1026
 	return $payment->email;
1027 1027
 }
@@ -1035,11 +1035,11 @@  discard block
 block discarded – undo
1035 1035
  *
1036 1036
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
1037 1037
  */
1038
-function give_is_guest_payment( $payment_id ) {
1039
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1040
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
1038
+function give_is_guest_payment($payment_id) {
1039
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1040
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1041 1041
 
1042
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1042
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1043 1043
 }
1044 1044
 
1045 1045
 /**
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
  *
1052 1052
  * @return int $user_id User ID.
1053 1053
  */
1054
-function give_get_payment_user_id( $payment_id ) {
1055
-	$payment = new Give_Payment( $payment_id );
1054
+function give_get_payment_user_id($payment_id) {
1055
+	$payment = new Give_Payment($payment_id);
1056 1056
 
1057 1057
 	return $payment->user_id;
1058 1058
 }
@@ -1066,8 +1066,8 @@  discard block
 block discarded – undo
1066 1066
  *
1067 1067
  * @return int $customer_id Customer ID.
1068 1068
  */
1069
-function give_get_payment_customer_id( $payment_id ) {
1070
-	$payment = new Give_Payment( $payment_id );
1069
+function give_get_payment_customer_id($payment_id) {
1070
+	$payment = new Give_Payment($payment_id);
1071 1071
 
1072 1072
 	return $payment->customer_id;
1073 1073
 }
@@ -1081,8 +1081,8 @@  discard block
 block discarded – undo
1081 1081
  *
1082 1082
  * @return string $ip User IP.
1083 1083
  */
1084
-function give_get_payment_user_ip( $payment_id ) {
1085
-	$payment = new Give_Payment( $payment_id );
1084
+function give_get_payment_user_ip($payment_id) {
1085
+	$payment = new Give_Payment($payment_id);
1086 1086
 
1087 1087
 	return $payment->ip;
1088 1088
 }
@@ -1096,8 +1096,8 @@  discard block
 block discarded – undo
1096 1096
  *
1097 1097
  * @return string $date The date the payment was completed.
1098 1098
  */
1099
-function give_get_payment_completed_date( $payment_id = 0 ) {
1100
-	$payment = new Give_Payment( $payment_id );
1099
+function give_get_payment_completed_date($payment_id = 0) {
1100
+	$payment = new Give_Payment($payment_id);
1101 1101
 
1102 1102
 	return $payment->completed_date;
1103 1103
 }
@@ -1111,8 +1111,8 @@  discard block
 block discarded – undo
1111 1111
  *
1112 1112
  * @return string $gateway Gateway.
1113 1113
  */
1114
-function give_get_payment_gateway( $payment_id ) {
1115
-	$payment = new Give_Payment( $payment_id );
1114
+function give_get_payment_gateway($payment_id) {
1115
+	$payment = new Give_Payment($payment_id);
1116 1116
 
1117 1117
 	return $payment->gateway;
1118 1118
 }
@@ -1126,8 +1126,8 @@  discard block
 block discarded – undo
1126 1126
  *
1127 1127
  * @return string $currency The currency code.
1128 1128
  */
1129
-function give_get_payment_currency_code( $payment_id = 0 ) {
1130
-	$payment = new Give_Payment( $payment_id );
1129
+function give_get_payment_currency_code($payment_id = 0) {
1130
+	$payment = new Give_Payment($payment_id);
1131 1131
 
1132 1132
 	return $payment->currency;
1133 1133
 }
@@ -1141,10 +1141,10 @@  discard block
 block discarded – undo
1141 1141
  *
1142 1142
  * @return string $currency The currency name.
1143 1143
  */
1144
-function give_get_payment_currency( $payment_id = 0 ) {
1145
-	$currency = give_get_payment_currency_code( $payment_id );
1144
+function give_get_payment_currency($payment_id = 0) {
1145
+	$currency = give_get_payment_currency_code($payment_id);
1146 1146
 
1147
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1147
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1148 1148
 }
1149 1149
 
1150 1150
 /**
@@ -1156,8 +1156,8 @@  discard block
 block discarded – undo
1156 1156
  *
1157 1157
  * @return string $key Donation key.
1158 1158
  */
1159
-function give_get_payment_key( $payment_id = 0 ) {
1160
-	$payment = new Give_Payment( $payment_id );
1159
+function give_get_payment_key($payment_id = 0) {
1160
+	$payment = new Give_Payment($payment_id);
1161 1161
 
1162 1162
 	return $payment->key;
1163 1163
 }
@@ -1173,8 +1173,8 @@  discard block
 block discarded – undo
1173 1173
  *
1174 1174
  * @return string $number Payment order number.
1175 1175
  */
1176
-function give_get_payment_number( $payment_id = 0 ) {
1177
-	$payment = new Give_Payment( $payment_id );
1176
+function give_get_payment_number($payment_id = 0) {
1177
+	$payment = new Give_Payment($payment_id);
1178 1178
 
1179 1179
 	return $payment->number;
1180 1180
 }
@@ -1188,23 +1188,23 @@  discard block
 block discarded – undo
1188 1188
  *
1189 1189
  * @return string      The formatted payment number.
1190 1190
  */
1191
-function give_format_payment_number( $number ) {
1191
+function give_format_payment_number($number) {
1192 1192
 
1193
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1193
+	if ( ! give_get_option('enable_sequential')) {
1194 1194
 		return $number;
1195 1195
 	}
1196 1196
 
1197
-	if ( ! is_numeric( $number ) ) {
1197
+	if ( ! is_numeric($number)) {
1198 1198
 		return $number;
1199 1199
 	}
1200 1200
 
1201
-	$prefix  = give_get_option( 'sequential_prefix' );
1202
-	$number  = absint( $number );
1203
-	$postfix = give_get_option( 'sequential_postfix' );
1201
+	$prefix  = give_get_option('sequential_prefix');
1202
+	$number  = absint($number);
1203
+	$postfix = give_get_option('sequential_postfix');
1204 1204
 
1205
-	$formatted_number = $prefix . $number . $postfix;
1205
+	$formatted_number = $prefix.$number.$postfix;
1206 1206
 
1207
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1207
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1208 1208
 }
1209 1209
 
1210 1210
 /**
@@ -1217,17 +1217,17 @@  discard block
 block discarded – undo
1217 1217
  */
1218 1218
 function give_get_next_payment_number() {
1219 1219
 
1220
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1220
+	if ( ! give_get_option('enable_sequential')) {
1221 1221
 		return false;
1222 1222
 	}
1223 1223
 
1224
-	$number           = get_option( 'give_last_payment_number' );
1225
-	$start            = give_get_option( 'sequential_start', 1 );
1224
+	$number           = get_option('give_last_payment_number');
1225
+	$start            = give_get_option('sequential_start', 1);
1226 1226
 	$increment_number = true;
1227 1227
 
1228
-	if ( false !== $number ) {
1228
+	if (false !== $number) {
1229 1229
 
1230
-		if ( empty( $number ) ) {
1230
+		if (empty($number)) {
1231 1231
 
1232 1232
 			$number           = $start;
1233 1233
 			$increment_number = false;
@@ -1236,24 +1236,24 @@  discard block
 block discarded – undo
1236 1236
 	} else {
1237 1237
 
1238 1238
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1239
-		$payments     = new Give_Payments_Query( array(
1239
+		$payments = new Give_Payments_Query(array(
1240 1240
 			'number'  => 1,
1241 1241
 			'order'   => 'DESC',
1242 1242
 			'orderby' => 'ID',
1243 1243
 			'output'  => 'posts',
1244 1244
 			'fields'  => 'ids',
1245
-		) );
1245
+		));
1246 1246
 		$last_payment = $payments->get_payments();
1247 1247
 
1248
-		if ( ! empty( $last_payment ) ) {
1248
+		if ( ! empty($last_payment)) {
1249 1249
 
1250
-			$number = give_get_payment_number( $last_payment[0] );
1250
+			$number = give_get_payment_number($last_payment[0]);
1251 1251
 
1252 1252
 		}
1253 1253
 
1254
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1254
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1255 1255
 
1256
-			$number = give_remove_payment_prefix_postfix( $number );
1256
+			$number = give_remove_payment_prefix_postfix($number);
1257 1257
 
1258 1258
 		} else {
1259 1259
 
@@ -1262,13 +1262,13 @@  discard block
 block discarded – undo
1262 1262
 		}
1263 1263
 	}
1264 1264
 
1265
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1265
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1266 1266
 
1267
-	if ( $increment_number ) {
1268
-		$number ++;
1267
+	if ($increment_number) {
1268
+		$number++;
1269 1269
 	}
1270 1270
 
1271
-	return apply_filters( 'give_get_next_payment_number', $number );
1271
+	return apply_filters('give_get_next_payment_number', $number);
1272 1272
 }
1273 1273
 
1274 1274
 /**
@@ -1280,25 +1280,25 @@  discard block
 block discarded – undo
1280 1280
  *
1281 1281
  * @return string The new Payment number without prefix and postfix.
1282 1282
  */
1283
-function give_remove_payment_prefix_postfix( $number ) {
1283
+function give_remove_payment_prefix_postfix($number) {
1284 1284
 
1285
-	$prefix  = give_get_option( 'sequential_prefix' );
1286
-	$postfix = give_get_option( 'sequential_postfix' );
1285
+	$prefix  = give_get_option('sequential_prefix');
1286
+	$postfix = give_get_option('sequential_postfix');
1287 1287
 
1288 1288
 	// Remove prefix.
1289
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1289
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1290 1290
 
1291 1291
 	// Remove the postfix.
1292
-	$length      = strlen( $number );
1293
-	$postfix_pos = strrpos( $number, $postfix );
1294
-	if ( false !== $postfix_pos ) {
1295
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1292
+	$length      = strlen($number);
1293
+	$postfix_pos = strrpos($number, $postfix);
1294
+	if (false !== $postfix_pos) {
1295
+		$number = substr_replace($number, '', $postfix_pos, $length);
1296 1296
 	}
1297 1297
 
1298 1298
 	// Ensure it's a whole number.
1299
-	$number = intval( $number );
1299
+	$number = intval($number);
1300 1300
 
1301
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1301
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1302 1302
 
1303 1303
 }
1304 1304
 
@@ -1315,10 +1315,10 @@  discard block
 block discarded – undo
1315 1315
  *
1316 1316
  * @return string $amount Fully formatted payment amount.
1317 1317
  */
1318
-function give_payment_amount( $payment_id = 0 ) {
1319
-	$amount = give_get_payment_amount( $payment_id );
1318
+function give_payment_amount($payment_id = 0) {
1319
+	$amount = give_get_payment_amount($payment_id);
1320 1320
 
1321
-	return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) );
1321
+	return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id));
1322 1322
 }
1323 1323
 
1324 1324
 /**
@@ -1331,11 +1331,11 @@  discard block
 block discarded – undo
1331 1331
  *
1332 1332
  * @return mixed|void
1333 1333
  */
1334
-function give_get_payment_amount( $payment_id ) {
1334
+function give_get_payment_amount($payment_id) {
1335 1335
 
1336
-	$payment = new Give_Payment( $payment_id );
1336
+	$payment = new Give_Payment($payment_id);
1337 1337
 
1338
-	return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id );
1338
+	return apply_filters('give_payment_amount', floatval($payment->total), $payment_id);
1339 1339
 }
1340 1340
 
1341 1341
 /**
@@ -1352,10 +1352,10 @@  discard block
 block discarded – undo
1352 1352
  *
1353 1353
  * @return array Fully formatted payment subtotal.
1354 1354
  */
1355
-function give_payment_subtotal( $payment_id = 0 ) {
1356
-	$subtotal = give_get_payment_subtotal( $payment_id );
1355
+function give_payment_subtotal($payment_id = 0) {
1356
+	$subtotal = give_get_payment_subtotal($payment_id);
1357 1357
 
1358
-	return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) );
1358
+	return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id));
1359 1359
 }
1360 1360
 
1361 1361
 /**
@@ -1369,8 +1369,8 @@  discard block
 block discarded – undo
1369 1369
  *
1370 1370
  * @return float $subtotal Subtotal for payment (non formatted).
1371 1371
  */
1372
-function give_get_payment_subtotal( $payment_id = 0 ) {
1373
-	$payment = new G_Payment( $payment_id );
1372
+function give_get_payment_subtotal($payment_id = 0) {
1373
+	$payment = new G_Payment($payment_id);
1374 1374
 
1375 1375
 	return $payment->subtotal;
1376 1376
 }
@@ -1385,10 +1385,10 @@  discard block
 block discarded – undo
1385 1385
  *
1386 1386
  * @return mixed array if payment fees found, false otherwise.
1387 1387
  */
1388
-function give_get_payment_fees( $payment_id = 0, $type = 'all' ) {
1389
-	$payment = new Give_Payment( $payment_id );
1388
+function give_get_payment_fees($payment_id = 0, $type = 'all') {
1389
+	$payment = new Give_Payment($payment_id);
1390 1390
 
1391
-	return $payment->get_fees( $type );
1391
+	return $payment->get_fees($type);
1392 1392
 }
1393 1393
 
1394 1394
 /**
@@ -1400,8 +1400,8 @@  discard block
 block discarded – undo
1400 1400
  *
1401 1401
  * @return string The donation ID.
1402 1402
  */
1403
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1404
-	$payment = new Give_Payment( $payment_id );
1403
+function give_get_payment_transaction_id($payment_id = 0) {
1404
+	$payment = new Give_Payment($payment_id);
1405 1405
 
1406 1406
 	return $payment->transaction_id;
1407 1407
 }
@@ -1416,15 +1416,15 @@  discard block
 block discarded – undo
1416 1416
  *
1417 1417
  * @return bool|mixed
1418 1418
  */
1419
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1419
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1420 1420
 
1421
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1421
+	if (empty($payment_id) || empty($transaction_id)) {
1422 1422
 		return false;
1423 1423
 	}
1424 1424
 
1425
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1425
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1426 1426
 
1427
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1427
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1428 1428
 }
1429 1429
 
1430 1430
 /**
@@ -1437,12 +1437,12 @@  discard block
 block discarded – undo
1437 1437
  *
1438 1438
  * @return int $purchase Donation ID.
1439 1439
  */
1440
-function give_get_purchase_id_by_key( $key ) {
1440
+function give_get_purchase_id_by_key($key) {
1441 1441
 	global $wpdb;
1442 1442
 
1443
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) );
1443
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key));
1444 1444
 
1445
-	if ( $purchase != null ) {
1445
+	if ($purchase != null) {
1446 1446
 		return $purchase;
1447 1447
 	}
1448 1448
 
@@ -1460,12 +1460,12 @@  discard block
 block discarded – undo
1460 1460
  *
1461 1461
  * @return int $purchase Donation ID.
1462 1462
  */
1463
-function give_get_purchase_id_by_transaction_id( $key ) {
1463
+function give_get_purchase_id_by_transaction_id($key) {
1464 1464
 	global $wpdb;
1465 1465
 
1466
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1466
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1467 1467
 
1468
-	if ( $purchase != null ) {
1468
+	if ($purchase != null) {
1469 1469
 		return $purchase;
1470 1470
 	}
1471 1471
 
@@ -1482,19 +1482,19 @@  discard block
 block discarded – undo
1482 1482
  *
1483 1483
  * @return array $notes Donation Notes
1484 1484
  */
1485
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1485
+function give_get_payment_notes($payment_id = 0, $search = '') {
1486 1486
 
1487
-	if ( empty( $payment_id ) && empty( $search ) ) {
1487
+	if (empty($payment_id) && empty($search)) {
1488 1488
 		return false;
1489 1489
 	}
1490 1490
 
1491
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1492
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1491
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1492
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1493 1493
 
1494
-	$notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) );
1494
+	$notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search));
1495 1495
 
1496
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1497
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1496
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1497
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1498 1498
 
1499 1499
 	return $notes;
1500 1500
 }
@@ -1510,8 +1510,8 @@  discard block
 block discarded – undo
1510 1510
  *
1511 1511
  * @return int The new note ID
1512 1512
  */
1513
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1514
-	if ( empty( $payment_id ) ) {
1513
+function give_insert_payment_note($payment_id = 0, $note = '') {
1514
+	if (empty($payment_id)) {
1515 1515
 		return false;
1516 1516
 	}
1517 1517
 
@@ -1523,14 +1523,14 @@  discard block
 block discarded – undo
1523 1523
 	 * @param int    $payment_id Payment ID.
1524 1524
 	 * @param string $note       The note.
1525 1525
 	 */
1526
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1526
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1527 1527
 
1528
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1528
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1529 1529
 		'comment_post_ID'      => $payment_id,
1530 1530
 		'comment_content'      => $note,
1531 1531
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1532
-		'comment_date'         => current_time( 'mysql' ),
1533
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1532
+		'comment_date'         => current_time('mysql'),
1533
+		'comment_date_gmt'     => current_time('mysql', 1),
1534 1534
 		'comment_approved'     => 1,
1535 1535
 		'comment_parent'       => 0,
1536 1536
 		'comment_author'       => '',
@@ -1539,7 +1539,7 @@  discard block
 block discarded – undo
1539 1539
 		'comment_author_email' => '',
1540 1540
 		'comment_type'         => 'give_payment_note',
1541 1541
 
1542
-	) ) );
1542
+	)));
1543 1543
 
1544 1544
 	/**
1545 1545
 	 * Fires after payment note inserted.
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
 	 * @param int    $payment_id Payment ID.
1551 1551
 	 * @param string $note       The note.
1552 1552
 	 */
1553
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1553
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1554 1554
 
1555 1555
 	return $note_id;
1556 1556
 }
@@ -1565,8 +1565,8 @@  discard block
 block discarded – undo
1565 1565
  *
1566 1566
  * @return bool True on success, false otherwise.
1567 1567
  */
1568
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1569
-	if ( empty( $comment_id ) ) {
1568
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1569
+	if (empty($comment_id)) {
1570 1570
 		return false;
1571 1571
 	}
1572 1572
 
@@ -1578,9 +1578,9 @@  discard block
 block discarded – undo
1578 1578
 	 * @param int $comment_id Note ID.
1579 1579
 	 * @param int $payment_id Payment ID.
1580 1580
 	 */
1581
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1581
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1582 1582
 
1583
-	$ret = wp_delete_comment( $comment_id, true );
1583
+	$ret = wp_delete_comment($comment_id, true);
1584 1584
 
1585 1585
 	/**
1586 1586
 	 * Fires after donation note deleted.
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
 	 * @param int $comment_id Note ID.
1591 1591
 	 * @param int $payment_id Payment ID.
1592 1592
 	 */
1593
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1593
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1594 1594
 
1595 1595
 	return $ret;
1596 1596
 }
@@ -1605,34 +1605,34 @@  discard block
 block discarded – undo
1605 1605
  *
1606 1606
  * @return string
1607 1607
  */
1608
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1608
+function give_get_payment_note_html($note, $payment_id = 0) {
1609 1609
 
1610
-	if ( is_numeric( $note ) ) {
1611
-		$note = get_comment( $note );
1610
+	if (is_numeric($note)) {
1611
+		$note = get_comment($note);
1612 1612
 	}
1613 1613
 
1614
-	if ( ! empty( $note->user_id ) ) {
1615
-		$user = get_userdata( $note->user_id );
1614
+	if ( ! empty($note->user_id)) {
1615
+		$user = get_userdata($note->user_id);
1616 1616
 		$user = $user->display_name;
1617 1617
 	} else {
1618
-		$user = esc_html__( 'System', 'give' );
1618
+		$user = esc_html__('System', 'give');
1619 1619
 	}
1620 1620
 
1621
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1621
+	$date_format = give_date_format().', '.get_option('time_format');
1622 1622
 
1623
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1623
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1624 1624
 		'give-action' => 'delete_payment_note',
1625 1625
 		'note_id'     => $note->comment_ID,
1626 1626
 		'payment_id'  => $payment_id,
1627
-	) ),
1628
-		'give_delete_payment_note_' . $note->comment_ID
1627
+	)),
1628
+		'give_delete_payment_note_'.$note->comment_ID
1629 1629
 	);
1630 1630
 
1631
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1631
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1632 1632
 	$note_html .= '<p>';
1633
-	$note_html .= '<strong>' . $user . '</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>';
1633
+	$note_html .= '<strong>'.$user.'</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>';
1634 1634
 	$note_html .= $note->comment_content;
1635
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>';
1635
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>';
1636 1636
 	$note_html .= '</p>';
1637 1637
 	$note_html .= '</div>';
1638 1638
 
@@ -1650,18 +1650,18 @@  discard block
 block discarded – undo
1650 1650
  *
1651 1651
  * @return void
1652 1652
  */
1653
-function give_hide_payment_notes( $query ) {
1654
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1655
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1656
-		if ( ! is_array( $types ) ) {
1657
-			$types = array( $types );
1653
+function give_hide_payment_notes($query) {
1654
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1655
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1656
+		if ( ! is_array($types)) {
1657
+			$types = array($types);
1658 1658
 		}
1659 1659
 		$types[]                           = 'give_payment_note';
1660 1660
 		$query->query_vars['type__not_in'] = $types;
1661 1661
 	}
1662 1662
 }
1663 1663
 
1664
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1664
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1665 1665
 
1666 1666
 /**
1667 1667
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1673,15 +1673,15 @@  discard block
 block discarded – undo
1673 1673
  *
1674 1674
  * @return array $clauses Updated comment clauses.
1675 1675
  */
1676
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1677
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1676
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1677
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1678 1678
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1679 1679
 	}
1680 1680
 
1681 1681
 	return $clauses;
1682 1682
 }
1683 1683
 
1684
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1684
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1685 1685
 
1686 1686
 
1687 1687
 /**
@@ -1694,15 +1694,15 @@  discard block
 block discarded – undo
1694 1694
  *
1695 1695
  * @return string $where
1696 1696
  */
1697
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1697
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1698 1698
 	global $wpdb;
1699 1699
 
1700
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1700
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1701 1701
 
1702 1702
 	return $where;
1703 1703
 }
1704 1704
 
1705
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1705
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1706 1706
 
1707 1707
 
1708 1708
 /**
@@ -1716,32 +1716,32 @@  discard block
 block discarded – undo
1716 1716
  *
1717 1717
  * @return array Array of comment counts.
1718 1718
  */
1719
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1719
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1720 1720
 	global $wpdb, $pagenow;
1721 1721
 
1722
-	if ( 'index.php' != $pagenow ) {
1722
+	if ('index.php' != $pagenow) {
1723 1723
 		return $stats;
1724 1724
 	}
1725 1725
 
1726 1726
 	$post_id = (int) $post_id;
1727 1727
 
1728
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1728
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1729 1729
 		return $stats;
1730 1730
 	}
1731 1731
 
1732
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1732
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1733 1733
 
1734
-	if ( false !== $stats ) {
1734
+	if (false !== $stats) {
1735 1735
 		return $stats;
1736 1736
 	}
1737 1737
 
1738 1738
 	$where = 'WHERE comment_type != "give_payment_note"';
1739 1739
 
1740
-	if ( $post_id > 0 ) {
1741
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1740
+	if ($post_id > 0) {
1741
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1742 1742
 	}
1743 1743
 
1744
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1744
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1745 1745
 
1746 1746
 	$total    = 0;
1747 1747
 	$approved = array(
@@ -1751,30 +1751,30 @@  discard block
 block discarded – undo
1751 1751
 		'trash'        => 'trash',
1752 1752
 		'post-trashed' => 'post-trashed',
1753 1753
 	);
1754
-	foreach ( (array) $count as $row ) {
1754
+	foreach ((array) $count as $row) {
1755 1755
 		// Don't count post-trashed toward totals.
1756
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1756
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1757 1757
 			$total += $row['num_comments'];
1758 1758
 		}
1759
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1760
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1759
+		if (isset($approved[$row['comment_approved']])) {
1760
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1761 1761
 		}
1762 1762
 	}
1763 1763
 
1764 1764
 	$stats['total_comments'] = $total;
1765
-	foreach ( $approved as $key ) {
1766
-		if ( empty( $stats[ $key ] ) ) {
1767
-			$stats[ $key ] = 0;
1765
+	foreach ($approved as $key) {
1766
+		if (empty($stats[$key])) {
1767
+			$stats[$key] = 0;
1768 1768
 		}
1769 1769
 	}
1770 1770
 
1771 1771
 	$stats = (object) $stats;
1772
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1772
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1773 1773
 
1774 1774
 	return $stats;
1775 1775
 }
1776 1776
 
1777
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1777
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1778 1778
 
1779 1779
 
1780 1780
 /**
@@ -1787,9 +1787,9 @@  discard block
 block discarded – undo
1787 1787
  *
1788 1788
  * @return string $where Modified where clause.
1789 1789
  */
1790
-function give_filter_where_older_than_week( $where = '' ) {
1790
+function give_filter_where_older_than_week($where = '') {
1791 1791
 	// Payments older than one week.
1792
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1792
+	$start = date('Y-m-d', strtotime('-7 days'));
1793 1793
 	$where .= " AND post_date <= '{$start}'";
1794 1794
 
1795 1795
 	return $where;
@@ -1809,38 +1809,38 @@  discard block
 block discarded – undo
1809 1809
  *
1810 1810
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1811 1811
  */
1812
-function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) {
1812
+function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') {
1813 1813
 
1814
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1815
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1816
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1814
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1815
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1816
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1817 1817
 
1818
-	if ( $only_level == true ) {
1818
+	if ($only_level == true) {
1819 1819
 		$form_title = '';
1820 1820
 	}
1821 1821
 
1822 1822
 	//If multi-level, append to the form title.
1823
-	if ( give_has_variable_prices( $form_id ) ) {
1823
+	if (give_has_variable_prices($form_id)) {
1824 1824
 
1825 1825
 		//Only add separator if there is a form title.
1826
-		if ( ! empty( $form_title ) ) {
1827
-			$form_title .= ' ' . $separator . ' ';
1826
+		if ( ! empty($form_title)) {
1827
+			$form_title .= ' '.$separator.' ';
1828 1828
 		}
1829 1829
 
1830 1830
 		$form_title .= '<span class="donation-level-text-wrap">';
1831 1831
 
1832
-		if ( $price_id == 'custom' ) {
1833
-			$custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true );
1834
-			$form_title         .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1832
+		if ($price_id == 'custom') {
1833
+			$custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true);
1834
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1835 1835
 		} else {
1836
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1836
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1837 1837
 		}
1838 1838
 
1839 1839
 		$form_title .= '</span>';
1840 1840
 
1841 1841
 	}
1842 1842
 
1843
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1843
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1844 1844
 
1845 1845
 }
1846 1846
 
@@ -1854,20 +1854,20 @@  discard block
 block discarded – undo
1854 1854
  *
1855 1855
  * @return string $price_id
1856 1856
  */
1857
-function give_get_price_id( $form_id, $price ) {
1857
+function give_get_price_id($form_id, $price) {
1858 1858
 
1859 1859
 	$price_id = 0;
1860 1860
 
1861
-	if ( give_has_variable_prices( $form_id ) ) {
1861
+	if (give_has_variable_prices($form_id)) {
1862 1862
 
1863
-		$levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) );
1863
+		$levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true));
1864 1864
 
1865
-		foreach ( $levels as $level ) {
1865
+		foreach ($levels as $level) {
1866 1866
 
1867
-			$level_amount = (float) give_sanitize_amount( $level['_give_amount'] );
1867
+			$level_amount = (float) give_sanitize_amount($level['_give_amount']);
1868 1868
 
1869 1869
 			// Check that this indeed the recurring price.
1870
-			if ( $level_amount == $price ) {
1870
+			if ($level_amount == $price) {
1871 1871
 
1872 1872
 				$price_id = $level['_give_id']['level_id'];
1873 1873
 
@@ -1892,10 +1892,10 @@  discard block
 block discarded – undo
1892 1892
  *
1893 1893
  * @return string|void
1894 1894
  */
1895
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1896
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1895
+function give_get_form_dropdown($args = array(), $echo = false) {
1896
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1897 1897
 
1898
-	if ( ! $echo ) {
1898
+	if ( ! $echo) {
1899 1899
 		return $form_dropdown_html;
1900 1900
 	}
1901 1901
 
@@ -1912,17 +1912,17 @@  discard block
 block discarded – undo
1912 1912
  *
1913 1913
  * @return string|bool
1914 1914
  */
1915
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1915
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1916 1916
 
1917 1917
 	// Check for give form id.
1918
-	if ( empty( $args['id'] ) ) {
1918
+	if (empty($args['id'])) {
1919 1919
 		return false;
1920 1920
 	}
1921 1921
 
1922
-	$form = new Give_Donate_Form( $args['id'] );
1922
+	$form = new Give_Donate_Form($args['id']);
1923 1923
 
1924 1924
 	// Check if form has variable prices or not.
1925
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1925
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1926 1926
 		return false;
1927 1927
 	}
1928 1928
 
@@ -1930,22 +1930,22 @@  discard block
 block discarded – undo
1930 1930
 	$variable_price_options = array();
1931 1931
 
1932 1932
 	// Check if multi donation form support custom donation or not.
1933
-	if ( $form->is_custom_price_mode() ) {
1934
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1933
+	if ($form->is_custom_price_mode()) {
1934
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1935 1935
 	}
1936 1936
 
1937 1937
 	// Get variable price and ID from variable price array.
1938
-	foreach ( $variable_prices as $variable_price ) {
1939
-		$variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'] ) );
1938
+	foreach ($variable_prices as $variable_price) {
1939
+		$variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount']));
1940 1940
 	}
1941 1941
 
1942 1942
 	// Update options.
1943
-	$args = array_merge( $args, array( 'options' => $variable_price_options ) );
1943
+	$args = array_merge($args, array('options' => $variable_price_options));
1944 1944
 
1945 1945
 	// Generate select html.
1946
-	$form_dropdown_html = Give()->html->select( $args );
1946
+	$form_dropdown_html = Give()->html->select($args);
1947 1947
 
1948
-	if ( ! $echo ) {
1948
+	if ( ! $echo) {
1949 1949
 		return $form_dropdown_html;
1950 1950
 	}
1951 1951
 
@@ -1964,14 +1964,14 @@  discard block
 block discarded – undo
1964 1964
  *
1965 1965
  * @return string
1966 1966
  */
1967
-function give_get_payment_meta_price_id( $payment_meta ) {
1967
+function give_get_payment_meta_price_id($payment_meta) {
1968 1968
 
1969
-	if(isset($payment_meta['give_price_id'])) {
1970
-		$price_id =  $payment_meta['give_price_id'];
1971
-	} elseif(isset($payment_meta['price_id'])) {
1972
-		$price_id =  $payment_meta['price_id'];
1969
+	if (isset($payment_meta['give_price_id'])) {
1970
+		$price_id = $payment_meta['give_price_id'];
1971
+	} elseif (isset($payment_meta['price_id'])) {
1972
+		$price_id = $payment_meta['price_id'];
1973 1973
 	} else {
1974
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1974
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1975 1975
 	}
1976 1976
 
1977 1977
 	return apply_filters('give_get_payment_meta_price_id', $price_id);
Please login to merge, or discard this patch.