Completed
Push — master ( e743f2...36b4cc )
by Devin
10s
created
includes/emails/template.php 1 patch
Spacing   +72 added lines, -72 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
 
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
  *
42 42
  * @return string $message Fully formatted message
43 43
  */
44
-function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) {
45
-	return give_do_email_tags( $message, $payment_id );
44
+function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) {
45
+	return give_do_email_tags($message, $payment_id);
46 46
 }
47 47
 
48 48
 /**
@@ -54,40 +54,40 @@  discard block
 block discarded – undo
54 54
  *
55 55
  * @return string $message Fully formatted message
56 56
  */
57
-function give_email_preview_template_tags( $message ) {
57
+function give_email_preview_template_tags($message) {
58 58
 
59
-	$price = give_currency_filter( give_format_amount( 10.50 ) );
59
+	$price = give_currency_filter(give_format_amount(10.50));
60 60
 
61 61
 	$gateway = 'PayPal';
62 62
 
63
-	$receipt_id = strtolower( md5( uniqid() ) );
63
+	$receipt_id = strtolower(md5(uniqid()));
64 64
 
65
-	$notes = esc_html( 'These are some sample notes added to a donation.', 'give' );
65
+	$notes = esc_html('These are some sample notes added to a donation.', 'give');
66 66
 
67
-	$payment_id = rand( 1, 100 );
67
+	$payment_id = rand(1, 100);
68 68
 
69 69
 	$receipt_link = sprintf(
70 70
 		'<a href="%1$s">%2$s</a>',
71
-		esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) ),
72
-		esc_html( 'View the receipt in your browser', 'give' )
71
+		esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url())),
72
+		esc_html('View the receipt in your browser', 'give')
73 73
 	);
74 74
 
75 75
 	$user = wp_get_current_user();
76 76
 
77
-	$message = str_replace( '{name}', $user->display_name, $message );
78
-	$message = str_replace( '{fullname}', $user->display_name, $message );
79
-	$message = str_replace( '{username}', $user->user_login, $message );
80
-	$message = str_replace( '{date}', date( get_option( 'date_format' ), current_time( 'timestamp' ) ), $message );
81
-	$message = str_replace( '{price}', $price, $message );
82
-	$message = str_replace( '{donation}', 'Sample Donation Form Title', $message );
83
-	$message = str_replace( '{receipt_id}', $receipt_id, $message );
84
-	$message = str_replace( '{payment_method}', $gateway, $message );
85
-	$message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message );
86
-	$message = str_replace( '{product_notes}', $notes, $message );
87
-	$message = str_replace( '{payment_id}', $payment_id, $message );
88
-	$message = str_replace( '{receipt_link}', $receipt_link, $message );
89
-
90
-	return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) );
77
+	$message = str_replace('{name}', $user->display_name, $message);
78
+	$message = str_replace('{fullname}', $user->display_name, $message);
79
+	$message = str_replace('{username}', $user->user_login, $message);
80
+	$message = str_replace('{date}', date(get_option('date_format'), current_time('timestamp')), $message);
81
+	$message = str_replace('{price}', $price, $message);
82
+	$message = str_replace('{donation}', 'Sample Donation Form Title', $message);
83
+	$message = str_replace('{receipt_id}', $receipt_id, $message);
84
+	$message = str_replace('{payment_method}', $gateway, $message);
85
+	$message = str_replace('{sitename}', get_bloginfo('name'), $message);
86
+	$message = str_replace('{product_notes}', $notes, $message);
87
+	$message = str_replace('{payment_id}', $payment_id, $message);
88
+	$message = str_replace('{receipt_link}', $receipt_link, $message);
89
+
90
+	return wpautop(apply_filters('give_email_preview_template_tags', $message));
91 91
 }
92 92
 
93 93
 /**
@@ -100,20 +100,20 @@  discard block
 block discarded – undo
100 100
  * @since  1.0
101 101
  * @return array|bool
102 102
  */
103
-add_filter( 'give_settings_emails', 'give_email_template_preview' );
103
+add_filter('give_settings_emails', 'give_email_template_preview');
104 104
 
105
-function give_email_template_preview( $array ) {
105
+function give_email_template_preview($array) {
106 106
 
107
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
107
+	if ( ! current_user_can('manage_give_settings')) {
108 108
 		return false;
109 109
 	}
110 110
 	$custom_field = array(
111
-		'name' => esc_html( 'Preview Email', 'give' ),
112
-		'desc' => esc_html( 'Click the buttons to preview emails.', 'give' ),
111
+		'name' => esc_html('Preview Email', 'give'),
112
+		'desc' => esc_html('Click the buttons to preview emails.', 'give'),
113 113
 		'id'   => 'give_email_preview_buttons',
114 114
 		'type' => 'email_preview_buttons'
115 115
 	);
116
-	array_splice( $array, 5, 0, array( $custom_field ) );
116
+	array_splice($array, 5, 0, array($custom_field));
117 117
 
118 118
 	return $array; // splice in at position 3;
119 119
 }
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
 function give_email_preview_buttons_callback() {
130 130
 	ob_start();
131 131
 	?>
132
-	<a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank" title="<?php esc_attr_e( 'Donation Receipt Preview', 'give' ); ?> "><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a>
133
-	<a href="<?php echo wp_nonce_url( add_query_arg( array(
132
+	<a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank" title="<?php esc_attr_e('Donation Receipt Preview', 'give'); ?> "><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a>
133
+	<a href="<?php echo wp_nonce_url(add_query_arg(array(
134 134
 		'give_action'  => 'send_test_email',
135 135
 		'give-message' => 'sent-test-email'
136
-	) ), 'give-test-email' ); ?>" title="<?php esc_attr_e( 'This will send a demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a>
136
+	)), 'give-test-email'); ?>" title="<?php esc_attr_e('This will send a demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a>
137 137
 	<?php
138 138
 	echo ob_get_clean();
139 139
 }
@@ -146,27 +146,27 @@  discard block
 block discarded – undo
146 146
  */
147 147
 function give_display_email_template_preview() {
148 148
 
149
-	if ( empty( $_GET['give_action'] ) ) {
149
+	if (empty($_GET['give_action'])) {
150 150
 		return;
151 151
 	}
152 152
 
153
-	if ( 'preview_email' !== $_GET['give_action'] ) {
153
+	if ('preview_email' !== $_GET['give_action']) {
154 154
 		return;
155 155
 	}
156 156
 
157
-	if ( ! current_user_can( 'manage_give_settings' ) ) {
157
+	if ( ! current_user_can('manage_give_settings')) {
158 158
 		return;
159 159
 	}
160 160
 
161
-	Give()->emails->heading = esc_html( 'Donation Receipt', 'give' );
161
+	Give()->emails->heading = esc_html('Donation Receipt', 'give');
162 162
 
163
-	echo Give()->emails->build_email( give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ) );
163
+	echo Give()->emails->build_email(give_email_preview_template_tags(give_get_email_body_content(0, array())));
164 164
 
165 165
 	exit;
166 166
 
167 167
 }
168 168
 
169
-add_action( 'template_redirect', 'give_display_email_template_preview' );
169
+add_action('template_redirect', 'give_display_email_template_preview');
170 170
 
171 171
 /**
172 172
  * Email Template Body
@@ -178,19 +178,19 @@  discard block
 block discarded – undo
178 178
  *
179 179
  * @return string $email_body Body of the email
180 180
  */
181
-function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) {
181
+function give_get_email_body_content($payment_id = 0, $payment_data = array()) {
182 182
 
183 183
 	global $give_options;
184 184
 
185 185
 	$default_email_body = give_get_default_donation_receipt_email();
186 186
 
187
-	$email = isset( $give_options['donation_receipt'] ) ? stripslashes( $give_options['donation_receipt'] ) : $default_email_body;
187
+	$email = isset($give_options['donation_receipt']) ? stripslashes($give_options['donation_receipt']) : $default_email_body;
188 188
 
189
-	$email_body = wpautop( $email );
189
+	$email_body = wpautop($email);
190 190
 
191
-	$email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data );
191
+	$email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data);
192 192
 
193
-	return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data );
193
+	return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data);
194 194
 }
195 195
 
196 196
 
@@ -206,41 +206,41 @@  discard block
 block discarded – undo
206 206
  *
207 207
  * @return string $email_body Body of the email
208 208
  */
209
-function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) {
209
+function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) {
210 210
 	global $give_options;
211 211
 
212
-	$user_info = maybe_unserialize( $payment_data['user_info'] );
213
-	$email     = give_get_payment_user_email( $payment_id );
212
+	$user_info = maybe_unserialize($payment_data['user_info']);
213
+	$email     = give_get_payment_user_email($payment_id);
214 214
 
215
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
216
-		$user_data = get_userdata( $user_info['id'] );
215
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
216
+		$user_data = get_userdata($user_info['id']);
217 217
 		$name      = $user_data->display_name;
218
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
219
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
218
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
219
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
220 220
 	} else {
221 221
 		$name = $email;
222 222
 	}
223 223
 
224
-	$gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) );
224
+	$gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true));
225 225
 
226
-	$default_email_body = esc_html( 'Hello', 'give' ) . "\n\n" . esc_html( 'A donation has been made', 'give' ) . ".\n\n";
226
+	$default_email_body = esc_html('Hello', 'give')."\n\n".esc_html('A donation has been made', 'give').".\n\n";
227 227
 	$default_email_body .= sprintf(
228 228
 		/* translators: %s: form plural label */
229
-		esc_html( '%s sold:', 'give' ),
229
+		esc_html('%s sold:', 'give'),
230 230
 		give_get_forms_label_plural()
231
-	) . "\n\n";
231
+	)."\n\n";
232 232
 
233
-	$default_email_body .= esc_html( 'Donor: ', 'give' ) . " " . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n";
234
-	$default_email_body .= esc_html( 'Amount: ', 'give' ) . " " . html_entity_decode( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n";
235
-	$default_email_body .= esc_html( 'Payment Method: ', 'give' ) . " " . $gateway . "\n\n";
233
+	$default_email_body .= esc_html('Donor: ', 'give')." ".html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n";
234
+	$default_email_body .= esc_html('Amount: ', 'give')." ".html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8')."\n";
235
+	$default_email_body .= esc_html('Payment Method: ', 'give')." ".$gateway."\n\n";
236 236
 
237
-	$default_email_body .= esc_html( 'Thank you', 'give' );
237
+	$default_email_body .= esc_html('Thank you', 'give');
238 238
 
239
-	$email = isset( $give_options['donation_notification'] ) ? stripslashes( $give_options['donation_notification'] ) : $default_email_body;
239
+	$email = isset($give_options['donation_notification']) ? stripslashes($give_options['donation_notification']) : $default_email_body;
240 240
 
241
-	$email_body = give_do_email_tags( $email, $payment_id );
241
+	$email_body = give_do_email_tags($email, $payment_id);
242 242
 
243
-	return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data );
243
+	return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data);
244 244
 }
245 245
 
246 246
 /**
@@ -253,15 +253,15 @@  discard block
 block discarded – undo
253 253
  * @since  1.0
254 254
  */
255 255
 function give_render_receipt_in_browser() {
256
-	if ( ! isset( $_GET['payment_key'] ) ) {
257
-		wp_die( esc_html( 'Missing donation payment key.', 'give' ), esc_html( 'Error', 'give' ) );
256
+	if ( ! isset($_GET['payment_key'])) {
257
+		wp_die(esc_html('Missing donation payment key.', 'give'), esc_html('Error', 'give'));
258 258
 	}
259 259
 
260
-	$key = urlencode( $_GET['payment_key'] );
260
+	$key = urlencode($_GET['payment_key']);
261 261
 
262 262
 	ob_start();
263 263
 	//Disallows caching of the page
264
-	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
264
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
265 265
 	header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
266 266
 	header("Cache-Control: post-check=0, pre-check=0", false);
267 267
 	header("Pragma: no-cache"); // HTTP/1.0
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	<!DOCTYPE html>
271 271
 	<html lang="en">
272 272
 		<head>
273
-			<title><?php esc_html_e( 'Donation Receipt', 'give' ); ?></title>
273
+			<title><?php esc_html_e('Donation Receipt', 'give'); ?></title>
274 274
 			<meta charset="utf-8" />
275 275
 
276 276
 			<!-- Further disallowing of caching of this page -->
@@ -284,12 +284,12 @@  discard block
 block discarded – undo
284 284
 
285 285
 			<?php wp_head(); ?>
286 286
 		</head>
287
-		<body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>">
287
+		<body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>">
288 288
 
289 289
 			<div id="give_receipt_wrapper">
290
-				<?php do_action( 'give_render_receipt_in_browser_before' ); ?>
291
-				<?php echo do_shortcode( '[give_receipt payment_key=' . $key . ']' ); ?>
292
-				<?php do_action( 'give_render_receipt_in_browser_after' ); ?>
290
+				<?php do_action('give_render_receipt_in_browser_before'); ?>
291
+				<?php echo do_shortcode('[give_receipt payment_key='.$key.']'); ?>
292
+				<?php do_action('give_render_receipt_in_browser_after'); ?>
293 293
 			</div>
294 294
 
295 295
 			<?php wp_footer(); ?>
@@ -300,4 +300,4 @@  discard block
 block discarded – undo
300 300
 	die();
301 301
 }
302 302
 
303
-add_action( 'give_view_receipt', 'give_render_receipt_in_browser' );
303
+add_action('give_view_receipt', 'give_render_receipt_in_browser');
Please login to merge, or discard this patch.
includes/emails/class-give-emails.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function __construct() {
81 81
 
82
-		if ( 'none' === $this->get_template() ) {
82
+		if ('none' === $this->get_template()) {
83 83
 			$this->html = false;
84 84
 		}
85 85
 
86
-		add_action( 'give_email_send_before', array( $this, 'send_before' ) );
87
-		add_action( 'give_email_send_after', array( $this, 'send_after' ) );
86
+		add_action('give_email_send_before', array($this, 'send_before'));
87
+		add_action('give_email_send_after', array($this, 'send_after'));
88 88
 
89 89
 	}
90 90
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 *
94 94
 	 * @since 1.0
95 95
 	 */
96
-	public function __set( $key, $value ) {
96
+	public function __set($key, $value) {
97 97
 		$this->$key = $value;
98 98
 	}
99 99
 
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 	 * @since 1.0
104 104
 	 */
105 105
 	public function get_from_name() {
106
-		if ( ! $this->from_name ) {
107
-			$this->from_name = give_get_option( 'from_name', get_bloginfo( 'name' ) );
106
+		if ( ! $this->from_name) {
107
+			$this->from_name = give_get_option('from_name', get_bloginfo('name'));
108 108
 		}
109 109
 
110
-		return apply_filters( 'give_email_from_name', wp_specialchars_decode( $this->from_name ), $this );
110
+		return apply_filters('give_email_from_name', wp_specialchars_decode($this->from_name), $this);
111 111
 	}
112 112
 
113 113
 	/**
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
 	 * @since 1.0
117 117
 	 */
118 118
 	public function get_from_address() {
119
-		if ( ! $this->from_address ) {
120
-			$this->from_address = give_get_option( 'from_email', get_option( 'admin_email' ) );
119
+		if ( ! $this->from_address) {
120
+			$this->from_address = give_get_option('from_email', get_option('admin_email'));
121 121
 		}
122 122
 
123
-		return apply_filters( 'give_email_from_address', $this->from_address, $this );
123
+		return apply_filters('give_email_from_address', $this->from_address, $this);
124 124
 	}
125 125
 
126 126
 	/**
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
 	 * @since 1.0
130 130
 	 */
131 131
 	public function get_content_type() {
132
-		if ( ! $this->content_type && $this->html ) {
133
-			$this->content_type = apply_filters( 'give_email_default_content_type', 'text/html', $this );
134
-		} else if ( ! $this->html ) {
132
+		if ( ! $this->content_type && $this->html) {
133
+			$this->content_type = apply_filters('give_email_default_content_type', 'text/html', $this);
134
+		} else if ( ! $this->html) {
135 135
 			$this->content_type = 'text/plain';
136 136
 		}
137 137
 
138
-		return apply_filters( 'give_email_content_type', $this->content_type, $this );
138
+		return apply_filters('give_email_content_type', $this->content_type, $this);
139 139
 	}
140 140
 
141 141
 	/**
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 	 * @since 1.0
145 145
 	 */
146 146
 	public function get_headers() {
147
-		if ( ! $this->headers ) {
147
+		if ( ! $this->headers) {
148 148
 			$this->headers = "From: {$this->get_from_name()} <{$this->get_from_address()}>\r\n";
149 149
 			$this->headers .= "Reply-To: {$this->get_from_address()}\r\n";
150 150
 			$this->headers .= "Content-Type: {$this->get_content_type()}; charset=utf-8\r\n";
151 151
 		}
152 152
 
153
-		return apply_filters( 'give_email_headers', $this->headers, $this );
153
+		return apply_filters('give_email_headers', $this->headers, $this);
154 154
 	}
155 155
 
156 156
 	/**
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	public function get_templates() {
162 162
 		$templates = array(
163
-			'default' => esc_html( 'Default Template', 'give' ),
164
-			'none'    => esc_html( 'No template, plain text only', 'give' )
163
+			'default' => esc_html('Default Template', 'give'),
164
+			'none'    => esc_html('No template, plain text only', 'give')
165 165
 		);
166 166
 
167
-		return apply_filters( 'give_email_templates', $templates );
167
+		return apply_filters('give_email_templates', $templates);
168 168
 	}
169 169
 
170 170
 	/**
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 	 * @since 1.0
174 174
 	 */
175 175
 	public function get_template() {
176
-		if ( ! $this->template ) {
177
-			$this->template = give_get_option( 'email_template', 'default' );
176
+		if ( ! $this->template) {
177
+			$this->template = give_get_option('email_template', 'default');
178 178
 		}
179 179
 
180
-		return apply_filters( 'give_email_template', $this->template );
180
+		return apply_filters('give_email_template', $this->template);
181 181
 	}
182 182
 
183 183
 	/**
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @since 1.0
187 187
 	 */
188 188
 	public function get_heading() {
189
-		return apply_filters( 'give_email_heading', $this->heading );
189
+		return apply_filters('give_email_heading', $this->heading);
190 190
 	}
191 191
 
192 192
 	/**
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return mixed
198 198
 	 */
199
-	public function parse_tags( $content ) {
199
+	public function parse_tags($content) {
200 200
 		return $content;
201 201
 	}
202 202
 
@@ -205,36 +205,36 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @since 1.0
207 207
 	 */
208
-	public function build_email( $message ) {
208
+	public function build_email($message) {
209 209
 
210
-		if ( false === $this->html ) {
211
-			return apply_filters( 'give_email_message', wp_strip_all_tags( $message ), $this );
210
+		if (false === $this->html) {
211
+			return apply_filters('give_email_message', wp_strip_all_tags($message), $this);
212 212
 		}
213 213
 
214
-		$message = $this->text_to_html( $message );
214
+		$message = $this->text_to_html($message);
215 215
 
216 216
 		ob_start();
217 217
 
218
-		give_get_template_part( 'emails/header', $this->get_template(), true );
218
+		give_get_template_part('emails/header', $this->get_template(), true);
219 219
 
220
-		do_action( 'give_email_header', $this );
220
+		do_action('give_email_header', $this);
221 221
 
222
-		if ( has_action( 'give_email_template_' . $this->get_template() ) ) {
223
-			do_action( 'give_email_template_' . $this->get_template() );
222
+		if (has_action('give_email_template_'.$this->get_template())) {
223
+			do_action('give_email_template_'.$this->get_template());
224 224
 		} else {
225
-			give_get_template_part( 'emails/body', $this->get_template(), true );
225
+			give_get_template_part('emails/body', $this->get_template(), true);
226 226
 		}
227 227
 
228
-		do_action( 'give_email_body', $this );
228
+		do_action('give_email_body', $this);
229 229
 
230
-		give_get_template_part( 'emails/footer', $this->get_template(), true );
230
+		give_get_template_part('emails/footer', $this->get_template(), true);
231 231
 
232
-		do_action( 'give_email_footer', $this );
232
+		do_action('give_email_footer', $this);
233 233
 
234 234
 		$body    = ob_get_clean();
235
-		$message = str_replace( '{email}', $message, $body );
235
+		$message = str_replace('{email}', $message, $body);
236 236
 
237
-		return apply_filters( 'give_email_message', $message, $this );
237
+		return apply_filters('give_email_message', $message, $this);
238 238
 	}
239 239
 
240 240
 	/**
@@ -247,26 +247,26 @@  discard block
 block discarded – undo
247 247
 	 *
248 248
 	 * @return bool
249 249
 	 */
250
-	public function send( $to, $subject, $message, $attachments = '' ) {
250
+	public function send($to, $subject, $message, $attachments = '') {
251 251
 
252
-		if ( ! did_action( 'init' ) && ! did_action( 'admin_init' ) ) {
253
-			_doing_it_wrong( __FUNCTION__, esc_html( 'You cannot send email with Give_Emails until init/admin_init has been reached.', 'give' ), null );
252
+		if ( ! did_action('init') && ! did_action('admin_init')) {
253
+			_doing_it_wrong(__FUNCTION__, esc_html('You cannot send email with Give_Emails until init/admin_init has been reached.', 'give'), null);
254 254
 
255 255
 			return false;
256 256
 		}
257 257
 
258
-		do_action( 'give_email_send_before', $this );
258
+		do_action('give_email_send_before', $this);
259 259
 
260
-		$subject = $this->parse_tags( $subject );
261
-		$message = $this->parse_tags( $message );
260
+		$subject = $this->parse_tags($subject);
261
+		$message = $this->parse_tags($message);
262 262
 
263
-		$message = $this->build_email( $message );
263
+		$message = $this->build_email($message);
264 264
 
265
-		$attachments = apply_filters( 'give_email_attachments', $attachments, $this );
265
+		$attachments = apply_filters('give_email_attachments', $attachments, $this);
266 266
 
267
-		$sent = wp_mail( $to, $subject, $message, $this->get_headers(), $attachments );
267
+		$sent = wp_mail($to, $subject, $message, $this->get_headers(), $attachments);
268 268
 
269
-		do_action( 'give_email_send_after', $this );
269
+		do_action('give_email_send_after', $this);
270 270
 
271 271
 		return $sent;
272 272
 
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
 	 * @since 1.0
279 279
 	 */
280 280
 	public function send_before() {
281
-		add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
282
-		add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
283
-		add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
281
+		add_filter('wp_mail_from', array($this, 'get_from_address'));
282
+		add_filter('wp_mail_from_name', array($this, 'get_from_name'));
283
+		add_filter('wp_mail_content_type', array($this, 'get_content_type'));
284 284
 	}
285 285
 
286 286
 	/**
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
 	 * @since 1.0
290 290
 	 */
291 291
 	public function send_after() {
292
-		remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
293
-		remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
294
-		remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ) );
292
+		remove_filter('wp_mail_from', array($this, 'get_from_address'));
293
+		remove_filter('wp_mail_from_name', array($this, 'get_from_name'));
294
+		remove_filter('wp_mail_content_type', array($this, 'get_content_type'));
295 295
 
296 296
 		// Reset heading to an empty string
297 297
 		$this->heading = '';
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 	 *
303 303
 	 * @since 1.0
304 304
 	 */
305
-	public function text_to_html( $message ) {
305
+	public function text_to_html($message) {
306 306
 
307
-		if ( 'text/html' == $this->content_type || true === $this->html ) {
308
-			$message = wpautop( $message );
307
+		if ('text/html' == $this->content_type || true === $this->html) {
308
+			$message = wpautop($message);
309 309
 		}
310 310
 
311 311
 		return $message;
Please login to merge, or discard this patch.
includes/class-give-customer.php 1 patch
Spacing   +128 added lines, -128 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
 
@@ -97,29 +97,29 @@  discard block
 block discarded – undo
97 97
 	 * @param bool $_id_or_email
98 98
 	 * @param bool $by_user_id
99 99
 	 */
100
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
100
+	public function __construct($_id_or_email = false, $by_user_id = false) {
101 101
 
102 102
 		$this->db = new Give_DB_Customers;
103 103
 
104
-		if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) {
104
+		if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) {
105 105
 			return false;
106 106
 		}
107 107
 
108
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
108
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
109 109
 
110
-		if ( is_numeric( $_id_or_email ) ) {
110
+		if (is_numeric($_id_or_email)) {
111 111
 			$field = $by_user_id ? 'user_id' : 'id';
112 112
 		} else {
113 113
 			$field = 'email';
114 114
 		}
115 115
 
116
-		$customer = $this->db->get_customer_by( $field, $_id_or_email );
116
+		$customer = $this->db->get_customer_by($field, $_id_or_email);
117 117
 
118
-		if ( empty( $customer ) || ! is_object( $customer ) ) {
118
+		if (empty($customer) || ! is_object($customer)) {
119 119
 			return false;
120 120
 		}
121 121
 
122
-		$this->setup_customer( $customer );
122
+		$this->setup_customer($customer);
123 123
 
124 124
 	}
125 125
 
@@ -132,15 +132,15 @@  discard block
 block discarded – undo
132 132
 	 *
133 133
 	 * @return bool             If the setup was successful or not
134 134
 	 */
135
-	private function setup_customer( $customer ) {
135
+	private function setup_customer($customer) {
136 136
 
137
-		if ( ! is_object( $customer ) ) {
137
+		if ( ! is_object($customer)) {
138 138
 			return false;
139 139
 		}
140 140
 
141
-		foreach ( $customer as $key => $value ) {
141
+		foreach ($customer as $key => $value) {
142 142
 
143
-			switch ( $key ) {
143
+			switch ($key) {
144 144
 
145 145
 				case 'notes':
146 146
 					$this->$key = $this->get_notes();
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		}
156 156
 
157 157
 		// Customer ID and email are the only things that are necessary, make sure they exist
158
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
158
+		if ( ! empty($this->id) && ! empty($this->email)) {
159 159
 			return true;
160 160
 		}
161 161
 
@@ -168,16 +168,16 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @since 1.0
170 170
 	 */
171
-	public function __get( $key ) {
171
+	public function __get($key) {
172 172
 
173
-		if ( method_exists( $this, 'get_' . $key ) ) {
173
+		if (method_exists($this, 'get_'.$key)) {
174 174
 
175
-			return call_user_func( array( $this, 'get_' . $key ) );
175
+			return call_user_func(array($this, 'get_'.$key));
176 176
 
177 177
 		} else {
178 178
 
179 179
 			/* translators: %s: property key */
180
-			return new WP_Error( 'give-customer-invalid-property', sprintf( esc_html( 'Can\'t get property %s.', 'give' ), $key ) );
180
+			return new WP_Error('give-customer-invalid-property', sprintf(esc_html('Can\'t get property %s.', 'give'), $key));
181 181
 
182 182
 		}
183 183
 
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	 *
193 193
 	 * @return mixed        False if not a valid creation, Customer ID if user is found or valid creation
194 194
 	 */
195
-	public function create( $data = array() ) {
195
+	public function create($data = array()) {
196 196
 
197
-		if ( $this->id != 0 || empty( $data ) ) {
197
+		if ($this->id != 0 || empty($data)) {
198 198
 			return false;
199 199
 		}
200 200
 
@@ -202,34 +202,34 @@  discard block
 block discarded – undo
202 202
 			'payment_ids' => ''
203 203
 		);
204 204
 
205
-		$args = wp_parse_args( $data, $defaults );
206
-		$args = $this->sanitize_columns( $args );
205
+		$args = wp_parse_args($data, $defaults);
206
+		$args = $this->sanitize_columns($args);
207 207
 
208
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
208
+		if (empty($args['email']) || ! is_email($args['email'])) {
209 209
 			return false;
210 210
 		}
211 211
 
212
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
213
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
212
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
213
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
214 214
 		}
215 215
 
216
-		do_action( 'give_customer_pre_create', $args );
216
+		do_action('give_customer_pre_create', $args);
217 217
 
218 218
 		$created = false;
219 219
 
220 220
 		// The DB class 'add' implies an update if the customer being asked to be created already exists
221
-		if ( $this->db->add( $data ) ) {
221
+		if ($this->db->add($data)) {
222 222
 
223 223
 			// We've successfully added/updated the customer, reset the class vars with the new data
224
-			$customer = $this->db->get_customer_by( 'email', $args['email'] );
224
+			$customer = $this->db->get_customer_by('email', $args['email']);
225 225
 
226 226
 			// Setup the customer data with the values from DB
227
-			$this->setup_customer( $customer );
227
+			$this->setup_customer($customer);
228 228
 
229 229
 			$created = $this->id;
230 230
 		}
231 231
 
232
-		do_action( 'give_customer_post_create', $created, $args );
232
+		do_action('give_customer_post_create', $created, $args);
233 233
 
234 234
 		return $created;
235 235
 
@@ -244,27 +244,27 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @return bool         If the update was successful or not
246 246
 	 */
247
-	public function update( $data = array() ) {
247
+	public function update($data = array()) {
248 248
 
249
-		if ( empty( $data ) ) {
249
+		if (empty($data)) {
250 250
 			return false;
251 251
 		}
252 252
 
253
-		$data = $this->sanitize_columns( $data );
253
+		$data = $this->sanitize_columns($data);
254 254
 
255
-		do_action( 'give_customer_pre_update', $this->id, $data );
255
+		do_action('give_customer_pre_update', $this->id, $data);
256 256
 
257 257
 		$updated = false;
258 258
 
259
-		if ( $this->db->update( $this->id, $data ) ) {
259
+		if ($this->db->update($this->id, $data)) {
260 260
 
261
-			$customer = $this->db->get_customer_by( 'id', $this->id );
262
-			$this->setup_customer( $customer );
261
+			$customer = $this->db->get_customer_by('id', $this->id);
262
+			$this->setup_customer($customer);
263 263
 
264 264
 			$updated = true;
265 265
 		}
266 266
 
267
-		do_action( 'give_customer_post_update', $updated, $this->id, $data );
267
+		do_action('give_customer_post_update', $updated, $this->id, $data);
268 268
 
269 269
 		return $updated;
270 270
 	}
@@ -280,44 +280,44 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @return bool            If the attachment was successfuly
282 282
 	 */
283
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
283
+	public function attach_payment($payment_id = 0, $update_stats = true) {
284 284
 
285
-		if ( empty( $payment_id ) ) {
285
+		if (empty($payment_id)) {
286 286
 			return false;
287 287
 		}
288 288
 
289
-		if ( empty( $this->payment_ids ) ) {
289
+		if (empty($this->payment_ids)) {
290 290
 
291 291
 			$new_payment_ids = $payment_id;
292 292
 
293 293
 		} else {
294 294
 
295
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
295
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
296 296
 
297
-			if ( in_array( $payment_id, $payment_ids ) ) {
297
+			if (in_array($payment_id, $payment_ids)) {
298 298
 				$update_stats = false;
299 299
 			}
300 300
 
301 301
 			$payment_ids[] = $payment_id;
302 302
 
303
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
303
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
304 304
 
305 305
 		}
306 306
 
307
-		do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id );
307
+		do_action('give_customer_pre_attach_payment', $payment_id, $this->id);
308 308
 
309
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
309
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
310 310
 
311
-		if ( $payment_added ) {
311
+		if ($payment_added) {
312 312
 
313 313
 			$this->payment_ids = $new_payment_ids;
314 314
 
315 315
 			// We added this payment successfully, increment the stats
316
-			if ( $update_stats ) {
317
-				$payment_amount = give_get_payment_amount( $payment_id );
316
+			if ($update_stats) {
317
+				$payment_amount = give_get_payment_amount($payment_id);
318 318
 
319
-				if ( ! empty( $payment_amount ) ) {
320
-					$this->increase_value( $payment_amount );
319
+				if ( ! empty($payment_amount)) {
320
+					$this->increase_value($payment_amount);
321 321
 				}
322 322
 
323 323
 				$this->increase_purchase_count();
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
 		}
327 327
 
328
-		do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id );
328
+		do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id);
329 329
 
330 330
 		return $payment_added;
331 331
 	}
@@ -341,50 +341,50 @@  discard block
 block discarded – undo
341 341
 	 *
342 342
 	 * @return boolean             If the removal was successful
343 343
 	 */
344
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
344
+	public function remove_payment($payment_id = 0, $update_stats = true) {
345 345
 
346
-		if ( empty( $payment_id ) ) {
346
+		if (empty($payment_id)) {
347 347
 			return false;
348 348
 		}
349 349
 
350
-		$payment = new Give_Payment( $payment_id );
350
+		$payment = new Give_Payment($payment_id);
351 351
 
352
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
352
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
353 353
 			$update_stats = false;
354 354
 		}
355 355
 
356 356
 		$new_payment_ids = '';
357 357
 
358
-		if ( ! empty( $this->payment_ids ) ) {
358
+		if ( ! empty($this->payment_ids)) {
359 359
 
360
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
360
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
361 361
 
362
-			$pos = array_search( $payment_id, $payment_ids );
363
-			if ( false === $pos ) {
362
+			$pos = array_search($payment_id, $payment_ids);
363
+			if (false === $pos) {
364 364
 				return false;
365 365
 			}
366 366
 
367
-			unset( $payment_ids[ $pos ] );
368
-			$payment_ids = array_filter( $payment_ids );
367
+			unset($payment_ids[$pos]);
368
+			$payment_ids = array_filter($payment_ids);
369 369
 
370
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
370
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
371 371
 
372 372
 		}
373 373
 
374
-		do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id );
374
+		do_action('give_customer_pre_remove_payment', $payment_id, $this->id);
375 375
 
376
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
376
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
377 377
 
378
-		if ( $payment_removed ) {
378
+		if ($payment_removed) {
379 379
 
380 380
 			$this->payment_ids = $new_payment_ids;
381 381
 
382
-			if ( $update_stats ) {
382
+			if ($update_stats) {
383 383
 				// We removed this payment successfully, decrement the stats
384
-				$payment_amount = give_get_payment_amount( $payment_id );
384
+				$payment_amount = give_get_payment_amount($payment_id);
385 385
 
386
-				if ( ! empty( $payment_amount ) ) {
387
-					$this->decrease_value( $payment_amount );
386
+				if ( ! empty($payment_amount)) {
387
+					$this->decrease_value($payment_amount);
388 388
 				}
389 389
 
390 390
 				$this->decrease_purchase_count();
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 
393 393
 		}
394 394
 
395
-		do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id );
395
+		do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id);
396 396
 
397 397
 		return $payment_removed;
398 398
 
@@ -407,22 +407,22 @@  discard block
 block discarded – undo
407 407
 	 *
408 408
 	 * @return int            The purchase count
409 409
 	 */
410
-	public function increase_purchase_count( $count = 1 ) {
410
+	public function increase_purchase_count($count = 1) {
411 411
 
412 412
 		// Make sure it's numeric and not negative
413
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
413
+		if ( ! is_numeric($count) || $count != absint($count)) {
414 414
 			return false;
415 415
 		}
416 416
 
417 417
 		$new_total = (int) $this->purchase_count + (int) $count;
418 418
 
419
-		do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id );
419
+		do_action('give_customer_pre_increase_purchase_count', $count, $this->id);
420 420
 
421
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
421
+		if ($this->update(array('purchase_count' => $new_total))) {
422 422
 			$this->purchase_count = $new_total;
423 423
 		}
424 424
 
425
-		do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id );
425
+		do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id);
426 426
 
427 427
 		return $this->purchase_count;
428 428
 	}
@@ -436,26 +436,26 @@  discard block
 block discarded – undo
436 436
 	 *
437 437
 	 * @return mixed          If successful, the new count, otherwise false
438 438
 	 */
439
-	public function decrease_purchase_count( $count = 1 ) {
439
+	public function decrease_purchase_count($count = 1) {
440 440
 
441 441
 		// Make sure it's numeric and not negative
442
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
442
+		if ( ! is_numeric($count) || $count != absint($count)) {
443 443
 			return false;
444 444
 		}
445 445
 
446 446
 		$new_total = (int) $this->purchase_count - (int) $count;
447 447
 
448
-		if ( $new_total < 0 ) {
448
+		if ($new_total < 0) {
449 449
 			$new_total = 0;
450 450
 		}
451 451
 
452
-		do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id );
452
+		do_action('give_customer_pre_decrease_purchase_count', $count, $this->id);
453 453
 
454
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
454
+		if ($this->update(array('purchase_count' => $new_total))) {
455 455
 			$this->purchase_count = $new_total;
456 456
 		}
457 457
 
458
-		do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id );
458
+		do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id);
459 459
 
460 460
 		return $this->purchase_count;
461 461
 	}
@@ -469,17 +469,17 @@  discard block
 block discarded – undo
469 469
 	 *
470 470
 	 * @return mixed         If successful, the new value, otherwise false
471 471
 	 */
472
-	public function increase_value( $value = 0.00 ) {
472
+	public function increase_value($value = 0.00) {
473 473
 
474
-		$new_value = floatval( $this->purchase_value ) + $value;
474
+		$new_value = floatval($this->purchase_value) + $value;
475 475
 
476
-		do_action( 'give_customer_pre_increase_value', $value, $this->id );
476
+		do_action('give_customer_pre_increase_value', $value, $this->id);
477 477
 
478
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
478
+		if ($this->update(array('purchase_value' => $new_value))) {
479 479
 			$this->purchase_value = $new_value;
480 480
 		}
481 481
 
482
-		do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id );
482
+		do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id);
483 483
 
484 484
 		return $this->purchase_value;
485 485
 	}
@@ -493,21 +493,21 @@  discard block
 block discarded – undo
493 493
 	 *
494 494
 	 * @return mixed         If successful, the new value, otherwise false
495 495
 	 */
496
-	public function decrease_value( $value = 0.00 ) {
496
+	public function decrease_value($value = 0.00) {
497 497
 
498
-		$new_value = floatval( $this->purchase_value ) - $value;
498
+		$new_value = floatval($this->purchase_value) - $value;
499 499
 
500
-		if ( $new_value < 0 ) {
500
+		if ($new_value < 0) {
501 501
 			$new_value = 0.00;
502 502
 		}
503 503
 
504
-		do_action( 'give_customer_pre_decrease_value', $value, $this->id );
504
+		do_action('give_customer_pre_decrease_value', $value, $this->id);
505 505
 
506
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
506
+		if ($this->update(array('purchase_value' => $new_value))) {
507 507
 			$this->purchase_value = $new_value;
508 508
 		}
509 509
 
510
-		do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id );
510
+		do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id);
511 511
 
512 512
 		return $this->purchase_value;
513 513
 	}
@@ -522,15 +522,15 @@  discard block
 block discarded – undo
522 522
 	 *
523 523
 	 * @return array           The notes requsted
524 524
 	 */
525
-	public function get_notes( $length = 20, $paged = 1 ) {
525
+	public function get_notes($length = 20, $paged = 1) {
526 526
 
527
-		$length = is_numeric( $length ) ? $length : 20;
528
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
527
+		$length = is_numeric($length) ? $length : 20;
528
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
529 529
 
530 530
 		$all_notes   = $this->get_raw_notes();
531
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
531
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
532 532
 
533
-		$desired_notes = array_slice( $notes_array, $offset, $length );
533
+		$desired_notes = array_slice($notes_array, $offset, $length);
534 534
 
535 535
 		return $desired_notes;
536 536
 
@@ -545,9 +545,9 @@  discard block
 block discarded – undo
545 545
 	public function get_notes_count() {
546 546
 
547 547
 		$all_notes   = $this->get_raw_notes();
548
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
548
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
549 549
 
550
-		return count( $notes_array );
550
+		return count($notes_array);
551 551
 
552 552
 	}
553 553
 
@@ -560,32 +560,32 @@  discard block
 block discarded – undo
560 560
 	 *
561 561
 	 * @return string|boolean The new note if added succesfully, false otherwise
562 562
 	 */
563
-	public function add_note( $note = '' ) {
563
+	public function add_note($note = '') {
564 564
 
565
-		$note = trim( $note );
566
-		if ( empty( $note ) ) {
565
+		$note = trim($note);
566
+		if (empty($note)) {
567 567
 			return false;
568 568
 		}
569 569
 
570 570
 		$notes = $this->get_raw_notes();
571 571
 
572
-		if ( empty( $notes ) ) {
572
+		if (empty($notes)) {
573 573
 			$notes = '';
574 574
 		}
575 575
 
576
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
577
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
578
-		$notes .= "\n\n" . $new_note;
576
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
577
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
578
+		$notes .= "\n\n".$new_note;
579 579
 
580
-		do_action( 'give_customer_pre_add_note', $new_note, $this->id );
580
+		do_action('give_customer_pre_add_note', $new_note, $this->id);
581 581
 
582
-		$updated = $this->update( array( 'notes' => $notes ) );
582
+		$updated = $this->update(array('notes' => $notes));
583 583
 
584
-		if ( $updated ) {
584
+		if ($updated) {
585 585
 			$this->notes = $this->get_notes();
586 586
 		}
587 587
 
588
-		do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id );
588
+		do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id);
589 589
 
590 590
 		// Return the formatted note, so we can test, as well as update any displays
591 591
 		return $new_note;
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 */
601 601
 	private function get_raw_notes() {
602 602
 
603
-		$all_notes = $this->db->get_column( 'notes', $this->id );
603
+		$all_notes = $this->db->get_column('notes', $this->id);
604 604
 
605 605
 		return $all_notes;
606 606
 
@@ -615,51 +615,51 @@  discard block
 block discarded – undo
615 615
 	 *
616 616
 	 * @return array       The sanitized data, based off column defaults
617 617
 	 */
618
-	private function sanitize_columns( $data ) {
618
+	private function sanitize_columns($data) {
619 619
 
620 620
 		$columns        = $this->db->get_columns();
621 621
 		$default_values = $this->db->get_column_defaults();
622 622
 
623
-		foreach ( $columns as $key => $type ) {
623
+		foreach ($columns as $key => $type) {
624 624
 
625 625
 			// Only sanitize data that we were provided
626
-			if ( ! array_key_exists( $key, $data ) ) {
626
+			if ( ! array_key_exists($key, $data)) {
627 627
 				continue;
628 628
 			}
629 629
 
630
-			switch ( $type ) {
630
+			switch ($type) {
631 631
 
632 632
 				case '%s':
633
-					if ( 'email' == $key ) {
634
-						$data[ $key ] = sanitize_email( $data[ $key ] );
635
-					} elseif ( 'notes' == $key ) {
636
-						$data[ $key ] = strip_tags( $data[ $key ] );
633
+					if ('email' == $key) {
634
+						$data[$key] = sanitize_email($data[$key]);
635
+					} elseif ('notes' == $key) {
636
+						$data[$key] = strip_tags($data[$key]);
637 637
 					} else {
638
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
638
+						$data[$key] = sanitize_text_field($data[$key]);
639 639
 					}
640 640
 					break;
641 641
 
642 642
 				case '%d':
643
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
644
-						$data[ $key ] = $default_values[ $key ];
643
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
644
+						$data[$key] = $default_values[$key];
645 645
 					} else {
646
-						$data[ $key ] = absint( $data[ $key ] );
646
+						$data[$key] = absint($data[$key]);
647 647
 					}
648 648
 					break;
649 649
 
650 650
 				case '%f':
651 651
 					// Convert what was given to a float
652
-					$value = floatval( $data[ $key ] );
652
+					$value = floatval($data[$key]);
653 653
 
654
-					if ( ! is_float( $value ) ) {
655
-						$data[ $key ] = $default_values[ $key ];
654
+					if ( ! is_float($value)) {
655
+						$data[$key] = $default_values[$key];
656 656
 					} else {
657
-						$data[ $key ] = $value;
657
+						$data[$key] = $value;
658 658
 					}
659 659
 					break;
660 660
 
661 661
 				default:
662
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
662
+					$data[$key] = sanitize_text_field($data[$key]);
663 663
 					break;
664 664
 
665 665
 			}
Please login to merge, or discard this patch.
includes/ajax-functions.php 1 patch
Spacing   +91 added lines, -91 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
 
@@ -25,27 +25,27 @@  discard block
 block discarded – undo
25 25
 function give_test_ajax_works() {
26 26
 
27 27
 	// Check if the Airplane Mode plugin is installed
28
-	if ( class_exists( 'Airplane_Mode_Core' ) ) {
28
+	if (class_exists('Airplane_Mode_Core')) {
29 29
 
30 30
 		$airplane = Airplane_Mode_Core::getInstance();
31 31
 
32
-		if ( method_exists( $airplane, 'enabled' ) ) {
32
+		if (method_exists($airplane, 'enabled')) {
33 33
 
34
-			if ( $airplane->enabled() ) {
34
+			if ($airplane->enabled()) {
35 35
 				return true;
36 36
 			}
37 37
 
38 38
 		} else {
39 39
 
40
-			if ( $airplane->check_status() == 'on' ) {
40
+			if ($airplane->check_status() == 'on') {
41 41
 				return true;
42 42
 			}
43 43
 		}
44 44
 	}
45 45
 
46
-	add_filter( 'block_local_requests', '__return_false' );
46
+	add_filter('block_local_requests', '__return_false');
47 47
 
48
-	if ( get_transient( '_give_ajax_works' ) ) {
48
+	if (get_transient('_give_ajax_works')) {
49 49
 		return true;
50 50
 	}
51 51
 
@@ -57,35 +57,35 @@  discard block
 block discarded – undo
57 57
 		)
58 58
 	);
59 59
 
60
-	$ajax  = wp_remote_post( give_get_ajax_url(), $params );
60
+	$ajax  = wp_remote_post(give_get_ajax_url(), $params);
61 61
 	$works = true;
62 62
 
63
-	if ( is_wp_error( $ajax ) ) {
63
+	if (is_wp_error($ajax)) {
64 64
 
65 65
 		$works = false;
66 66
 
67 67
 	} else {
68 68
 
69
-		if ( empty( $ajax['response'] ) ) {
69
+		if (empty($ajax['response'])) {
70 70
 			$works = false;
71 71
 		}
72 72
 
73
-		if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) {
73
+		if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) {
74 74
 			$works = false;
75 75
 		}
76 76
 
77
-		if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) {
77
+		if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) {
78 78
 			$works = false;
79 79
 		}
80 80
 
81
-		if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) {
81
+		if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) {
82 82
 			$works = false;
83 83
 		}
84 84
 
85 85
 	}
86 86
 
87
-	if ( $works ) {
88
-		set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS );
87
+	if ($works) {
88
+		set_transient('_give_ajax_works', '1', DAY_IN_SECONDS);
89 89
 	}
90 90
 
91 91
 	return $works;
@@ -99,16 +99,16 @@  discard block
 block discarded – undo
99 99
  * @return string
100 100
  */
101 101
 function give_get_ajax_url() {
102
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
102
+	$scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin';
103 103
 
104 104
 	$current_url = give_get_current_page_url();
105
-	$ajax_url    = admin_url( 'admin-ajax.php', $scheme );
105
+	$ajax_url    = admin_url('admin-ajax.php', $scheme);
106 106
 
107
-	if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
108
-		$ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
107
+	if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) {
108
+		$ajax_url = preg_replace('/^http/', 'https', $ajax_url);
109 109
 	}
110 110
 
111
-	return apply_filters( 'give_ajax_url', $ajax_url );
111
+	return apply_filters('give_ajax_url', $ajax_url);
112 112
 }
113 113
 
114 114
 /**
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
  * @return void
119 119
  */
120 120
 function give_load_checkout_login_fields() {
121
-	do_action( 'give_purchase_form_login_fields' );
121
+	do_action('give_purchase_form_login_fields');
122 122
 	give_die();
123 123
 }
124 124
 
125
-add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' );
125
+add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields');
126 126
 
127 127
 /**
128 128
  * Load Checkout Fields
@@ -131,22 +131,22 @@  discard block
 block discarded – undo
131 131
  * @return void
132 132
  */
133 133
 function give_load_checkout_fields() {
134
-	$form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : '';
134
+	$form_id = isset($_POST['form_id']) ? $_POST['form_id'] : '';
135 135
 
136 136
 	ob_start();
137 137
 
138
-	do_action( 'give_purchase_form_register_login_fields', $form_id );
138
+	do_action('give_purchase_form_register_login_fields', $form_id);
139 139
 
140 140
 	$fields = ob_get_clean();
141 141
 
142
-	wp_send_json( array(
143
-		'fields' => wp_json_encode( $fields ),
144
-		'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ),
145
-	) );
142
+	wp_send_json(array(
143
+		'fields' => wp_json_encode($fields),
144
+		'submit' => wp_json_encode(give_checkout_button_purchase($form_id)),
145
+	));
146 146
 }
147 147
 
148
-add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' );
149
-add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' );
148
+add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields');
149
+add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields');
150 150
 
151 151
 /**
152 152
  * Get Form Title via AJAX (used only in WordPress Admin)
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
  * @return void
156 156
  */
157 157
 function give_ajax_get_form_title() {
158
-	if ( isset( $_POST['form_id'] ) ) {
159
-		$title = get_the_title( $_POST['form_id'] );
160
-		if ( $title ) {
158
+	if (isset($_POST['form_id'])) {
159
+		$title = get_the_title($_POST['form_id']);
160
+		if ($title) {
161 161
 			echo $title;
162 162
 		} else {
163 163
 			echo 'fail';
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 	give_die();
167 167
 }
168 168
 
169
-add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' );
170
-add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' );
169
+add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title');
170
+add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title');
171 171
 
172 172
 /**
173 173
  * Retrieve a states drop down
@@ -177,23 +177,23 @@  discard block
 block discarded – undo
177 177
  */
178 178
 function give_ajax_get_states_field() {
179 179
 
180
-	if ( empty( $_POST['country'] ) ) {
180
+	if (empty($_POST['country'])) {
181 181
 		$_POST['country'] = give_get_country();
182 182
 	}
183
-	$states = give_get_states( $_POST['country'] );
183
+	$states = give_get_states($_POST['country']);
184 184
 
185
-	if ( ! empty( $states ) ) {
185
+	if ( ! empty($states)) {
186 186
 
187 187
 		$args = array(
188 188
 			'name'             => $_POST['field_name'],
189 189
 			'id'               => $_POST['field_name'],
190
-			'class'            => $_POST['field_name'] . '  give-select',
191
-			'options'          => give_get_states( $_POST['country'] ),
190
+			'class'            => $_POST['field_name'].'  give-select',
191
+			'options'          => give_get_states($_POST['country']),
192 192
 			'show_option_all'  => false,
193 193
 			'show_option_none' => false
194 194
 		);
195 195
 
196
-		$response = Give()->html->select( $args );
196
+		$response = Give()->html->select($args);
197 197
 
198 198
 	} else {
199 199
 
@@ -205,8 +205,8 @@  discard block
 block discarded – undo
205 205
 	give_die();
206 206
 }
207 207
 
208
-add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' );
209
-add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' );
208
+add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field');
209
+add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field');
210 210
 
211 211
 /**
212 212
  * Retrieve a states drop down
@@ -217,17 +217,17 @@  discard block
 block discarded – undo
217 217
 function give_ajax_form_search() {
218 218
 	global $wpdb;
219 219
 
220
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
220
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
221 221
 	$results = array();
222
-	if ( current_user_can( 'edit_give_forms' ) ) {
223
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" );
222
+	if (current_user_can('edit_give_forms')) {
223
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50");
224 224
 	} else {
225
-		$items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" );
225
+		$items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50");
226 226
 	}
227 227
 
228
-	if ( $items ) {
228
+	if ($items) {
229 229
 
230
-		foreach ( $items as $item ) {
230
+		foreach ($items as $item) {
231 231
 
232 232
 			$results[] = array(
233 233
 				'id'   => $item->ID,
@@ -239,18 +239,18 @@  discard block
 block discarded – undo
239 239
 
240 240
 		$items[] = array(
241 241
 			'id'   => 0,
242
-			'name' => esc_html( 'No results found', 'give' )
242
+			'name' => esc_html('No results found', 'give')
243 243
 		);
244 244
 
245 245
 	}
246 246
 
247
-	echo json_encode( $results );
247
+	echo json_encode($results);
248 248
 
249 249
 	give_die();
250 250
 }
251 251
 
252
-add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' );
253
-add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' );
252
+add_action('wp_ajax_give_form_search', 'give_ajax_form_search');
253
+add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search');
254 254
 
255 255
 /**
256 256
  * Search the donors database via Ajax
@@ -261,21 +261,21 @@  discard block
 block discarded – undo
261 261
 function give_ajax_donor_search() {
262 262
 	global $wpdb;
263 263
 
264
-	$search  = esc_sql( sanitize_text_field( $_GET['s'] ) );
264
+	$search  = esc_sql(sanitize_text_field($_GET['s']));
265 265
 	$results = array();
266
-	if ( ! current_user_can( 'view_give_reports' ) ) {
266
+	if ( ! current_user_can('view_give_reports')) {
267 267
 		$donors = array();
268 268
 	} else {
269
-		$donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" );
269
+		$donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50");
270 270
 	}
271 271
 
272
-	if ( $donors ) {
272
+	if ($donors) {
273 273
 
274
-		foreach ( $donors as $donor ) {
274
+		foreach ($donors as $donor) {
275 275
 
276 276
 			$results[] = array(
277 277
 				'id'   => $donor->id,
278
-				'name' => $donor->name . '(' . $donor->email . ')'
278
+				'name' => $donor->name.'('.$donor->email.')'
279 279
 			);
280 280
 		}
281 281
 
@@ -283,17 +283,17 @@  discard block
 block discarded – undo
283 283
 
284 284
 		$donors[] = array(
285 285
 			'id'   => 0,
286
-			'name' => esc_html( 'No results found', 'give' )
286
+			'name' => esc_html('No results found', 'give')
287 287
 		);
288 288
 
289 289
 	}
290 290
 
291
-	echo json_encode( $results );
291
+	echo json_encode($results);
292 292
 
293 293
 	give_die();
294 294
 }
295 295
 
296
-add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' );
296
+add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search');
297 297
 
298 298
 
299 299
 /**
@@ -304,42 +304,42 @@  discard block
 block discarded – undo
304 304
  */
305 305
 function give_ajax_search_users() {
306 306
 
307
-	if ( current_user_can( 'manage_give_settings' ) ) {
307
+	if (current_user_can('manage_give_settings')) {
308 308
 
309
-		$search_query = trim( $_POST['user_name'] );
310
-		$exclude      = trim( $_POST['exclude'] );
309
+		$search_query = trim($_POST['user_name']);
310
+		$exclude      = trim($_POST['exclude']);
311 311
 
312 312
 		$get_users_args = array(
313 313
 			'number' => 9999,
314
-			'search' => $search_query . '*'
314
+			'search' => $search_query.'*'
315 315
 		);
316 316
 
317
-		if ( ! empty( $exclude ) ) {
318
-			$exclude_array             = explode( ',', $exclude );
317
+		if ( ! empty($exclude)) {
318
+			$exclude_array             = explode(',', $exclude);
319 319
 			$get_users_args['exclude'] = $exclude_array;
320 320
 		}
321 321
 
322
-		$get_users_args = apply_filters( 'give_search_users_args', $get_users_args );
322
+		$get_users_args = apply_filters('give_search_users_args', $get_users_args);
323 323
 
324
-		$found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query );
324
+		$found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query);
325 325
 
326 326
 		$user_list = '<ul>';
327
-		if ( $found_users ) {
328
-			foreach ( $found_users as $user ) {
329
-				$user_list .= '<li><a href="#" data-userid="' . esc_attr( $user->ID ) . '" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>';
327
+		if ($found_users) {
328
+			foreach ($found_users as $user) {
329
+				$user_list .= '<li><a href="#" data-userid="'.esc_attr($user->ID).'" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>';
330 330
 			}
331 331
 		} else {
332
-			$user_list .= '<li>' . esc_html( 'No users found', 'give' ) . '</li>';
332
+			$user_list .= '<li>'.esc_html('No users found', 'give').'</li>';
333 333
 		}
334 334
 		$user_list .= '</ul>';
335 335
 
336
-		echo json_encode( array( 'results' => $user_list ) );
336
+		echo json_encode(array('results' => $user_list));
337 337
 
338 338
 	}
339 339
 	die();
340 340
 }
341 341
 
342
-add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' );
342
+add_action('wp_ajax_give_search_users', 'give_ajax_search_users');
343 343
 
344 344
 
345 345
 /**
@@ -350,32 +350,32 @@  discard block
 block discarded – undo
350 350
  */
351 351
 function give_check_for_form_price_variations() {
352 352
 
353
-	if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) {
354
-		die( '-1' );
353
+	if ( ! current_user_can('edit_give_forms', get_current_user_id())) {
354
+		die('-1');
355 355
 	}
356 356
 
357
-	$form_id = intval( $_POST['form_id'] );
358
-	$form    = get_post( $form_id );
357
+	$form_id = intval($_POST['form_id']);
358
+	$form    = get_post($form_id);
359 359
 
360
-	if ( 'give_forms' != $form->post_type ) {
361
-		die( '-2' );
360
+	if ('give_forms' != $form->post_type) {
361
+		die('-2');
362 362
 	}
363 363
 
364
-	if ( give_has_variable_prices( $form_id ) ) {
365
-		$variable_prices = give_get_variable_prices( $form_id );
364
+	if (give_has_variable_prices($form_id)) {
365
+		$variable_prices = give_get_variable_prices($form_id);
366 366
 
367
-		if ( $variable_prices ) {
367
+		if ($variable_prices) {
368 368
 			$ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">';
369 369
 
370
-			if ( isset( $_POST['all_prices'] ) ) {
371
-				$ajax_response .= '<option value="">' . esc_html( 'All Levels', 'give' ) . '</option>';
370
+			if (isset($_POST['all_prices'])) {
371
+				$ajax_response .= '<option value="">'.esc_html('All Levels', 'give').'</option>';
372 372
 			}
373 373
 
374
-			foreach ( $variable_prices as $key => $price ) {
374
+			foreach ($variable_prices as $key => $price) {
375 375
 
376
-				$level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) );
376
+				$level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount']));
377 377
 				
378
-				$ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>';
378
+				$ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>';
379 379
 			}
380 380
 			$ajax_response .= '</select>';
381 381
 			echo $ajax_response;
@@ -386,4 +386,4 @@  discard block
 block discarded – undo
386 386
 	give_die();
387 387
 }
388 388
 
389
-add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' );
389
+add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations');
Please login to merge, or discard this patch.
includes/post-types.php 1 patch
Spacing   +135 added lines, -135 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,40 +23,40 @@  discard block
 block discarded – undo
23 23
 function give_setup_post_types() {
24 24
 
25 25
 	/** Give Forms Post Type */
26
-	$give_forms_singular = give_get_option( 'disable_forms_singular' ) !== 'on' ? true : false;
26
+	$give_forms_singular = give_get_option('disable_forms_singular') !== 'on' ? true : false;
27 27
 
28
-	$give_forms_archives = give_get_option( 'disable_forms_archives' ) !== 'on' ? true : false;
28
+	$give_forms_archives = give_get_option('disable_forms_archives') !== 'on' ? true : false;
29 29
 
30
-	$give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations';
30
+	$give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations';
31 31
 	//support for old 'GIVE_FORMS_SLUG' constant
32
-	if ( defined( 'GIVE_FORMS_SLUG' ) ) {
32
+	if (defined('GIVE_FORMS_SLUG')) {
33 33
 		$give_forms_slug = GIVE_FORMS_SLUG;
34 34
 	}
35 35
 
36
-	$give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array(
36
+	$give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array(
37 37
 		'slug'       => $give_forms_slug,
38 38
 		'with_front' => false
39 39
 	);
40 40
 
41
-	$give_forms_labels = apply_filters( 'give_forms_labels', array(
42
-		'name'               => esc_html( 'Donation %2$s', 'give' ),
41
+	$give_forms_labels = apply_filters('give_forms_labels', array(
42
+		'name'               => esc_html('Donation %2$s', 'give'),
43 43
 		'singular_name'      => '%1$s',
44
-		'add_new'            => esc_html( 'Add %1$s', 'give' ),
45
-		'add_new_item'       => esc_html( 'Add New Donation %1$s', 'give' ),
46
-		'edit_item'          => esc_html( 'Edit Donation %1$s', 'give' ),
47
-		'new_item'           => esc_html( 'New %1$s', 'give' ),
48
-		'all_items'          => esc_html( 'All %2$s', 'give' ),
49
-		'view_item'          => esc_html( 'View %1$s', 'give' ),
50
-		'search_items'       => esc_html( 'Search %2$s', 'give' ),
51
-		'not_found'          => esc_html( 'No %2$s found', 'give' ),
52
-		'not_found_in_trash' => esc_html( 'No %2$s found in Trash', 'give' ),
44
+		'add_new'            => esc_html('Add %1$s', 'give'),
45
+		'add_new_item'       => esc_html('Add New Donation %1$s', 'give'),
46
+		'edit_item'          => esc_html('Edit Donation %1$s', 'give'),
47
+		'new_item'           => esc_html('New %1$s', 'give'),
48
+		'all_items'          => esc_html('All %2$s', 'give'),
49
+		'view_item'          => esc_html('View %1$s', 'give'),
50
+		'search_items'       => esc_html('Search %2$s', 'give'),
51
+		'not_found'          => esc_html('No %2$s found', 'give'),
52
+		'not_found_in_trash' => esc_html('No %2$s found in Trash', 'give'),
53 53
 		'parent_item_colon'  => '',
54
-		'menu_name'          => apply_filters( 'give_menu_name', esc_html( 'Donations', 'give' ) ),
55
-		'name_admin_bar'     => apply_filters( 'give_name_admin_bar_name', esc_html( 'Donation Form', 'give' ) )
56
-	) );
54
+		'menu_name'          => apply_filters('give_menu_name', esc_html('Donations', 'give')),
55
+		'name_admin_bar'     => apply_filters('give_name_admin_bar_name', esc_html('Donation Form', 'give'))
56
+	));
57 57
 
58
-	foreach ( $give_forms_labels as $key => $value ) {
59
-		$give_forms_labels[ $key ] = sprintf( $value, give_get_forms_label_singular(), give_get_forms_label_plural() );
58
+	foreach ($give_forms_labels as $key => $value) {
59
+		$give_forms_labels[$key] = sprintf($value, give_get_forms_label_singular(), give_get_forms_label_plural());
60 60
 	}
61 61
 
62 62
 	//Default give_forms supports
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 	);
70 70
 
71 71
 	//Has the user disabled the excerpt
72
-	if ( give_get_option( 'disable_forms_excerpt' ) === 'on' ) {
73
-		unset( $give_form_supports[2] );
72
+	if (give_get_option('disable_forms_excerpt') === 'on') {
73
+		unset($give_form_supports[2]);
74 74
 	}
75 75
 
76 76
 	//Has user disabled the featured image?
77
-	if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) {
78
-		unset( $give_form_supports[1] );
79
-		remove_action( 'give_before_single_form_summary', 'give_show_form_images' );
77
+	if (give_get_option('disable_form_featured_img') === 'on') {
78
+		unset($give_form_supports[1]);
79
+		remove_action('give_before_single_form_summary', 'give_show_form_images');
80 80
 	}
81 81
 
82 82
 	$give_forms_args = array(
@@ -92,42 +92,42 @@  discard block
 block discarded – undo
92 92
 		'has_archive'        => $give_forms_archives,
93 93
 		'menu_icon'          => 'dashicons-give',
94 94
 		'hierarchical'       => false,
95
-		'supports'           => apply_filters( 'give_forms_supports', $give_form_supports ),
95
+		'supports'           => apply_filters('give_forms_supports', $give_form_supports),
96 96
 	);
97
-	register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) );
97
+	register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args));
98 98
 	
99 99
 	/** Payment Post Type */
100 100
 	$payment_labels = array(
101
-		'name'               => _x( 'Donations', 'post type general name', 'give' ),
102
-		'singular_name'      => _x( 'Donation', 'post type singular name', 'give' ),
103
-		'add_new'            => esc_html( 'Add New', 'give' ),
104
-		'add_new_item'       => esc_html( 'Add New Donation', 'give' ),
105
-		'edit_item'          => esc_html( 'Edit Donation', 'give' ),
106
-		'new_item'           => esc_html( 'New Donation', 'give' ),
107
-		'all_items'          => esc_html( 'All Donations', 'give' ),
108
-		'view_item'          => esc_html( 'View Donation', 'give' ),
109
-		'search_items'       => esc_html( 'Search Donations', 'give' ),
110
-		'not_found'          => esc_html( 'No Donations found', 'give' ),
111
-		'not_found_in_trash' => esc_html( 'No Donations found in Trash', 'give' ),
101
+		'name'               => _x('Donations', 'post type general name', 'give'),
102
+		'singular_name'      => _x('Donation', 'post type singular name', 'give'),
103
+		'add_new'            => esc_html('Add New', 'give'),
104
+		'add_new_item'       => esc_html('Add New Donation', 'give'),
105
+		'edit_item'          => esc_html('Edit Donation', 'give'),
106
+		'new_item'           => esc_html('New Donation', 'give'),
107
+		'all_items'          => esc_html('All Donations', 'give'),
108
+		'view_item'          => esc_html('View Donation', 'give'),
109
+		'search_items'       => esc_html('Search Donations', 'give'),
110
+		'not_found'          => esc_html('No Donations found', 'give'),
111
+		'not_found_in_trash' => esc_html('No Donations found in Trash', 'give'),
112 112
 		'parent_item_colon'  => '',
113
-		'menu_name'          => esc_html( 'Transactions', 'give' )
113
+		'menu_name'          => esc_html('Transactions', 'give')
114 114
 	);
115 115
 
116 116
 	$payment_args = array(
117
-		'labels'          => apply_filters( 'give_payment_labels', $payment_labels ),
117
+		'labels'          => apply_filters('give_payment_labels', $payment_labels),
118 118
 		'public'          => false,
119 119
 		'query_var'       => false,
120 120
 		'rewrite'         => false,
121 121
 		'map_meta_cap'    => true,
122 122
 		'capability_type' => 'give_payment',
123
-		'supports'        => array( 'title' ),
123
+		'supports'        => array('title'),
124 124
 		'can_export'      => true
125 125
 	);
126
-	register_post_type( 'give_payment', $payment_args );
126
+	register_post_type('give_payment', $payment_args);
127 127
 
128 128
 }
129 129
 
130
-add_action( 'init', 'give_setup_post_types', 1 );
130
+add_action('init', 'give_setup_post_types', 1);
131 131
 
132 132
 
133 133
 /**
@@ -140,32 +140,32 @@  discard block
 block discarded – undo
140 140
  */
141 141
 function give_setup_taxonomies() {
142 142
 
143
-	$slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations';
143
+	$slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations';
144 144
 
145 145
 	/** Categories */
146 146
 	$category_labels = array(
147 147
 		/* translators: %s: form singular label */
148
-		'name'              => sprintf( _x( '%s Categories', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ),
149
-		'singular_name'     => _x( 'Category', 'taxonomy singular name', 'give' ),
150
-		'search_items'      => esc_html( 'Search Categories', 'give' ),
151
-		'all_items'         => esc_html( 'All Categories', 'give' ),
152
-		'parent_item'       => esc_html( 'Parent Category', 'give' ),
153
-		'parent_item_colon' => esc_html( 'Parent Category:', 'give' ),
154
-		'edit_item'         => esc_html( 'Edit Category', 'give' ),
155
-		'update_item'       => esc_html( 'Update Category', 'give' ),
148
+		'name'              => sprintf(_x('%s Categories', 'taxonomy general name', 'give'), give_get_forms_label_singular()),
149
+		'singular_name'     => _x('Category', 'taxonomy singular name', 'give'),
150
+		'search_items'      => esc_html('Search Categories', 'give'),
151
+		'all_items'         => esc_html('All Categories', 'give'),
152
+		'parent_item'       => esc_html('Parent Category', 'give'),
153
+		'parent_item_colon' => esc_html('Parent Category:', 'give'),
154
+		'edit_item'         => esc_html('Edit Category', 'give'),
155
+		'update_item'       => esc_html('Update Category', 'give'),
156 156
 		/* translators: %s: form singular label */
157
-		'add_new_item'      => sprintf( esc_html( 'Add New %s Category', 'give' ), give_get_forms_label_singular() ),
158
-		'new_item_name'     => esc_html( 'New Category Name', 'give' ),
159
-		'menu_name'         => esc_html( 'Categories', 'give' ),
157
+		'add_new_item'      => sprintf(esc_html('Add New %s Category', 'give'), give_get_forms_label_singular()),
158
+		'new_item_name'     => esc_html('New Category Name', 'give'),
159
+		'menu_name'         => esc_html('Categories', 'give'),
160 160
 	);
161 161
 
162
-	$category_args = apply_filters( 'give_forms_category_args', array(
162
+	$category_args = apply_filters('give_forms_category_args', array(
163 163
 			'hierarchical' => true,
164
-			'labels'       => apply_filters( 'give_forms_category_labels', $category_labels ),
164
+			'labels'       => apply_filters('give_forms_category_labels', $category_labels),
165 165
 			'show_ui'      => true,
166 166
 			'query_var'    => 'give_forms_category',
167 167
 			'rewrite'      => array(
168
-				'slug'         => $slug . '/category',
168
+				'slug'         => $slug.'/category',
169 169
 				'with_front'   => false,
170 170
 				'hierarchical' => true
171 171
 			),
@@ -179,36 +179,36 @@  discard block
 block discarded – undo
179 179
 	);
180 180
 
181 181
 	//Does the user want categories?
182
-	if ( give_get_option( 'enable_categories' ) == 'on' ) {
183
-		register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args );
184
-		register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' );
182
+	if (give_get_option('enable_categories') == 'on') {
183
+		register_taxonomy('give_forms_category', array('give_forms'), $category_args);
184
+		register_taxonomy_for_object_type('give_forms_category', 'give_forms');
185 185
 	}
186 186
 
187 187
 
188 188
 	/** Tags */
189 189
 	$tag_labels = array(
190 190
 		/* translators: %s: form singular label */
191
-		'name'                  => sprintf( _x( '%s Tags', 'taxonomy general name', 'give' ), give_get_forms_label_singular() ),
192
-		'singular_name'         => _x( 'Tag', 'taxonomy singular name', 'give' ),
193
-		'search_items'          => esc_html( 'Search Tags', 'give' ),
194
-		'all_items'             => esc_html( 'All Tags', 'give' ),
195
-		'parent_item'           => esc_html( 'Parent Tag', 'give' ),
196
-		'parent_item_colon'     => esc_html( 'Parent Tag:', 'give' ),
197
-		'edit_item'             => esc_html( 'Edit Tag', 'give' ),
198
-		'update_item'           => esc_html( 'Update Tag', 'give' ),
199
-		'add_new_item'          => esc_html( 'Add New Tag', 'give' ),
200
-		'new_item_name'         => esc_html( 'New Tag Name', 'give' ),
201
-		'menu_name'             => esc_html( 'Tags', 'give' ),
191
+		'name'                  => sprintf(_x('%s Tags', 'taxonomy general name', 'give'), give_get_forms_label_singular()),
192
+		'singular_name'         => _x('Tag', 'taxonomy singular name', 'give'),
193
+		'search_items'          => esc_html('Search Tags', 'give'),
194
+		'all_items'             => esc_html('All Tags', 'give'),
195
+		'parent_item'           => esc_html('Parent Tag', 'give'),
196
+		'parent_item_colon'     => esc_html('Parent Tag:', 'give'),
197
+		'edit_item'             => esc_html('Edit Tag', 'give'),
198
+		'update_item'           => esc_html('Update Tag', 'give'),
199
+		'add_new_item'          => esc_html('Add New Tag', 'give'),
200
+		'new_item_name'         => esc_html('New Tag Name', 'give'),
201
+		'menu_name'             => esc_html('Tags', 'give'),
202 202
 		/* translators: %s: form singular label */
203
-		'choose_from_most_used' => sprintf( esc_html( 'Choose from most used %s tags.', 'give' ), give_get_forms_label_singular() ),
203
+		'choose_from_most_used' => sprintf(esc_html('Choose from most used %s tags.', 'give'), give_get_forms_label_singular()),
204 204
 	);
205 205
 
206
-	$tag_args = apply_filters( 'give_forms_tag_args', array(
206
+	$tag_args = apply_filters('give_forms_tag_args', array(
207 207
 			'hierarchical' => false,
208
-			'labels'       => apply_filters( 'give_forms_tag_labels', $tag_labels ),
208
+			'labels'       => apply_filters('give_forms_tag_labels', $tag_labels),
209 209
 			'show_ui'      => true,
210 210
 			'query_var'    => 'give_forms_tag',
211
-			'rewrite'      => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ),
211
+			'rewrite'      => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true),
212 212
 			'capabilities' => array(
213 213
 				'manage_terms' => 'manage_give_forms_terms',
214 214
 				'edit_terms'   => 'edit_give_forms_terms',
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
 		)
220 220
 	);
221 221
 
222
-	if ( give_get_option( 'enable_tags' ) == 'on' ) {
223
-		register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args );
224
-		register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' );
222
+	if (give_get_option('enable_tags') == 'on') {
223
+		register_taxonomy('give_forms_tag', array('give_forms'), $tag_args);
224
+		register_taxonomy_for_object_type('give_forms_tag', 'give_forms');
225 225
 	}
226 226
 
227 227
 
228 228
 }
229 229
 
230
-add_action( 'init', 'give_setup_taxonomies', 0 );
230
+add_action('init', 'give_setup_taxonomies', 0);
231 231
 
232 232
 
233 233
 /**
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
  */
239 239
 function give_get_default_form_labels() {
240 240
 	$defaults = array(
241
-		'singular' => esc_html( 'Form', 'give' ),
242
-		'plural'   => esc_html( 'Forms', 'give' )
241
+		'singular' => esc_html('Form', 'give'),
242
+		'plural'   => esc_html('Forms', 'give')
243 243
 	);
244 244
 
245
-	return apply_filters( 'give_default_form_name', $defaults );
245
+	return apply_filters('give_default_form_name', $defaults);
246 246
 }
247 247
 
248 248
 /**
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
  *
255 255
  * @return string $defaults['singular'] Singular label
256 256
  */
257
-function give_get_forms_label_singular( $lowercase = false ) {
257
+function give_get_forms_label_singular($lowercase = false) {
258 258
 	$defaults = give_get_default_form_labels();
259 259
 
260
-	return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
260
+	return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
261 261
 }
262 262
 
263 263
 /**
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
  * @since 1.0
267 267
  * @return string $defaults['plural'] Plural label
268 268
  */
269
-function give_get_forms_label_plural( $lowercase = false ) {
269
+function give_get_forms_label_plural($lowercase = false) {
270 270
 	$defaults = give_get_default_form_labels();
271 271
 
272
-	return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
272
+	return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
273 273
 }
274 274
 
275 275
 /**
@@ -281,12 +281,12 @@  discard block
 block discarded – undo
281 281
  *
282 282
  * @return string $title New placeholder text
283 283
  */
284
-function give_change_default_title( $title ) {
284
+function give_change_default_title($title) {
285 285
 	// If a frontend plugin uses this filter (check extensions before changing this function)
286
-	if ( ! is_admin() ) {
286
+	if ( ! is_admin()) {
287 287
 		$title = sprintf(
288 288
 			/* translators: %s: form singular label */
289
-			esc_html( 'Enter %s title here', 'give' ),
289
+			esc_html('Enter %s title here', 'give'),
290 290
 			give_get_forms_label_singular()
291 291
 		);
292 292
 
@@ -295,10 +295,10 @@  discard block
 block discarded – undo
295 295
 
296 296
 	$screen = get_current_screen();
297 297
 
298
-	if ( 'give_forms' == $screen->post_type ) {
298
+	if ('give_forms' == $screen->post_type) {
299 299
 		$title = sprintf(
300 300
 			/* translators: %s: form singular label */
301
-			esc_html( 'Enter %s title here', 'give' ),
301
+			esc_html('Enter %s title here', 'give'),
302 302
 			give_get_forms_label_singular()
303 303
 		);
304 304
 	}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	return $title;
307 307
 }
308 308
 
309
-add_filter( 'enter_title_here', 'give_change_default_title' );
309
+add_filter('enter_title_here', 'give_change_default_title');
310 310
 
311 311
 /**
312 312
  * Registers Custom Post Statuses which are used by the Payments
@@ -316,50 +316,50 @@  discard block
 block discarded – undo
316 316
  */
317 317
 function give_register_post_type_statuses() {
318 318
 	// Payment Statuses
319
-	register_post_status( 'refunded', array(
320
-		'label'                     => _x( 'Refunded', 'Refunded payment status', 'give' ),
319
+	register_post_status('refunded', array(
320
+		'label'                     => _x('Refunded', 'Refunded payment status', 'give'),
321 321
 		'public'                    => true,
322 322
 		'exclude_from_search'       => false,
323 323
 		'show_in_admin_all_list'    => true,
324 324
 		'show_in_admin_status_list' => true,
325
-		'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' )
326
-	) );
327
-	register_post_status( 'failed', array(
328
-		'label'                     => _x( 'Failed', 'Failed payment status', 'give' ),
325
+		'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give')
326
+	));
327
+	register_post_status('failed', array(
328
+		'label'                     => _x('Failed', 'Failed payment status', 'give'),
329 329
 		'public'                    => true,
330 330
 		'exclude_from_search'       => false,
331 331
 		'show_in_admin_all_list'    => true,
332 332
 		'show_in_admin_status_list' => true,
333
-		'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' )
334
-	) );
335
-	register_post_status( 'revoked', array(
336
-		'label'                     => _x( 'Revoked', 'Revoked payment status', 'give' ),
333
+		'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give')
334
+	));
335
+	register_post_status('revoked', array(
336
+		'label'                     => _x('Revoked', 'Revoked payment status', 'give'),
337 337
 		'public'                    => true,
338 338
 		'exclude_from_search'       => false,
339 339
 		'show_in_admin_all_list'    => true,
340 340
 		'show_in_admin_status_list' => true,
341
-		'label_count'               => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' )
342
-	) );
343
-	register_post_status( 'cancelled', array(
344
-		'label'                     => _x( 'Cancelled', 'Cancelled payment status', 'give' ),
341
+		'label_count'               => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give')
342
+	));
343
+	register_post_status('cancelled', array(
344
+		'label'                     => _x('Cancelled', 'Cancelled payment status', 'give'),
345 345
 		'public'                    => true,
346 346
 		'exclude_from_search'       => false,
347 347
 		'show_in_admin_all_list'    => true,
348 348
 		'show_in_admin_status_list' => true,
349
-		'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' )
350
-	) );
351
-	register_post_status( 'abandoned', array(
352
-		'label'                     => _x( 'Abandoned', 'Abandoned payment status', 'give' ),
349
+		'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give')
350
+	));
351
+	register_post_status('abandoned', array(
352
+		'label'                     => _x('Abandoned', 'Abandoned payment status', 'give'),
353 353
 		'public'                    => true,
354 354
 		'exclude_from_search'       => false,
355 355
 		'show_in_admin_all_list'    => true,
356 356
 		'show_in_admin_status_list' => true,
357
-		'label_count'               => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' )
358
-	) );
357
+		'label_count'               => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give')
358
+	));
359 359
 
360 360
 }
361 361
 
362
-add_action( 'init', 'give_register_post_type_statuses' );
362
+add_action('init', 'give_register_post_type_statuses');
363 363
 
364 364
 /**
365 365
  * Updated Messages
@@ -372,43 +372,43 @@  discard block
 block discarded – undo
372 372
  *
373 373
  * @return array $messages New post updated messages
374 374
  */
375
-function give_updated_messages( $messages ) {
375
+function give_updated_messages($messages) {
376 376
 	global $post, $post_ID;
377 377
 
378
-	$url1 = '<a href="' . get_permalink( $post_ID ) . '">';
378
+	$url1 = '<a href="'.get_permalink($post_ID).'">';
379 379
 	$url2 = give_get_forms_label_singular();
380 380
 	$url3 = '</a>';
381 381
 
382 382
 	$messages['give_forms'] = array(
383
-		1 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
384
-		4 => sprintf( __( '%2$s updated. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
385
-		6 => sprintf( __( '%2$s published. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
386
-		7 => sprintf( __( '%2$s saved. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 ),
387
-		8 => sprintf( __( '%2$s submitted. %1$sView %2$s%3$s.', 'give' ), $url1, $url2, $url3 )
383
+		1 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
384
+		4 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
385
+		6 => sprintf(__('%2$s published. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
386
+		7 => sprintf(__('%2$s saved. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3),
387
+		8 => sprintf(__('%2$s submitted. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3)
388 388
 	);
389 389
 
390 390
 	return $messages;
391 391
 }
392 392
 
393
-add_filter( 'post_updated_messages', 'give_updated_messages' );
393
+add_filter('post_updated_messages', 'give_updated_messages');
394 394
 
395 395
 
396 396
 /**
397 397
  * Setup Post Type Images
398 398
  */
399
-add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 );
399
+add_action('after_setup_theme', 'give_add_thumbnail_support', 10);
400 400
 
401 401
 /**
402 402
  * Ensure post thumbnail support is turned on
403 403
  */
404 404
 function give_add_thumbnail_support() {
405
-	if ( give_get_option( 'disable_form_featured_img' ) === 'on' ) {
405
+	if (give_get_option('disable_form_featured_img') === 'on') {
406 406
 		return;
407 407
 	}
408
-	if ( ! current_theme_supports( 'post-thumbnails' ) ) {
409
-		add_theme_support( 'post-thumbnails' );
408
+	if ( ! current_theme_supports('post-thumbnails')) {
409
+		add_theme_support('post-thumbnails');
410 410
 	}
411
-	add_post_type_support( 'give_forms', 'thumbnail' );
411
+	add_post_type_support('give_forms', 'thumbnail');
412 412
 }
413 413
 
414 414
 /**
@@ -420,19 +420,19 @@  discard block
 block discarded – undo
420 420
 function give_widgets_init() {
421 421
 
422 422
 	//Single Give Forms (disabled if single turned off in settings)
423
-	if ( give_get_option( 'disable_forms_singular' ) !== 'on' && give_get_option( 'disable_form_sidebar' ) !== 'on' ) {
423
+	if (give_get_option('disable_forms_singular') !== 'on' && give_get_option('disable_form_sidebar') !== 'on') {
424 424
 
425
-		register_sidebar( apply_filters( 'give_forms_single_sidebar', array(
426
-			'name'          => esc_html( 'Give Single Form Sidebar', 'give' ),
425
+		register_sidebar(apply_filters('give_forms_single_sidebar', array(
426
+			'name'          => esc_html('Give Single Form Sidebar', 'give'),
427 427
 			'id'            => 'give-forms-sidebar',
428
-			'description'   => esc_html( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ),
428
+			'description'   => esc_html('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'),
429 429
 			'before_widget' => '<div id="%1$s" class="widget %2$s">',
430 430
 			'after_widget'  => '</div>',
431 431
 			'before_title'  => '<h3 class="widgettitle widget-title">',
432 432
 			'after_title'   => '</h3>',
433
-		) ) );
433
+		)));
434 434
 
435 435
 	}
436 436
 }
437 437
 
438
-add_action( 'widgets_init', 'give_widgets_init', 999 );
438
+add_action('widgets_init', 'give_widgets_init', 999);
Please login to merge, or discard this patch.